deleting the last key in a dictionary - vb.net

One of the keys in my dictionary is like this == > O "Models"
I want to delete this key. I know that this will be the last key always
I tried:
file1dictionary.Remove(O "Models")
file1dictionary.Remove("O "Models"")
Both have syntax errors

Double quotes in VB.Net strings are self-escaped, meaning you use two of them within the string literal to represent a quote contained in the string object, like this:
file1dictionary.Remove("O ""Models""")

Related

SQL request to find item in table by value in column

Its pretty simple question, I know, but I really stacked with a problem with it...
I have a table customer_customer and a column code in it. So I need to find all items with a specific code value. So I wrote that:
SELECT * FROM customer_customer WHERE code LIKE "КL-12345"
and got an error:
column "КL-12345" does not exist
Why КL-12345 became a column if I specify it as value of code column? What am I doing wrong?
String literals must be enclosed in single quotes.
By enclosing it in double quotes, you specified a variable name.
Also, note that your where condition is the same as writing
where code = 'КL-12345'
LIKE is used for pattern matching. For instance you would match all codes that contain 'KL-12345' like this
where code like '%KL-12345%'
Change it to single quotes
SELECT * FROM customer_customer WHERE code LIKE 'КL-12345'
or
SELECT * FROM customer_customer WHERE code = 'КL-12345'

Match multiple occurences of string A in string B in business objects

Is there a way to match multiple occurences of string A in string B? Match only return a boolean and Pos only returns the index of the first match it finds.
Maybe split the string into an iterable array based on a common delimiter and return a count somehow?
Well this is one way to solve it. It's not pretty but it works.
=(Length([stringB]) - Length(Replace([stringB];"stringA";""))) / Length("stringA")

Private are mapping of unichar in Cocoa

In NSEvent in key down event it has characters property and it has a character like 'a' as the first character when you hit a key 'a'.
When I hit down-arrow key I get 63233 as a decimal expression of the first character.
I wonder what is the number and I found that 63233 = 0xF701 is in a private area in Unicode according to http://en.wikipedia.org/wiki/Private_Use_(Unicode) .
What I want to know is how and where they are defined. Is there any document which lists up all the character mappings used in Cocoa??
The NSText class reference contains the character mappings of common command and modifier keys. The Down Arrow key is specifically defined as NSDownTextMovement = 0x16. A more complete list can be found in HIToolbox, a sub-framework of Carbon in Events.h

Access numeric NSDictionary key in NSPredicate

I'm trying to write a predicate to check a specific value in a dictionary I have set up.
This dictionary has string versions of "0", "1", and "2" as keys which I would like to access.
The predicate I would like to write is:
$player.currencyDictionaries.0.earned > 1000
The problem is that .0 is not allowed. Assuming I cannot easily change how the dictionary stores values (this is in older versions and I'd like to use the same predicate on all versions as it is hosted on a server) is there any way to access the data?
IIRC, you can do this:
$player.currencyDictionaries[0].earned > 1000
(You might need to do ['0'] to guarantee that the passed value is a string and not a number)
Note that this syntax ([0]) only works in predicate format strings. It does not work with key paths.
This syntax is defined under the "Index Expression" section of the Predicate BNF.
EDIT
Actually, this won't work, and here's why:
The string "$player.currencyDictionaries[0].earned" will be read and turned into an NSExpression of type NSKeyPathExpression. This means, when it's evaluated, it's going to basically take that string and run it through the receiver's -valueForKeyPath: method. As I mentioned above, the bracket syntax doesn't work with key paths, and thus this will produce the incorrect answer.
However, since you know the currencyDictionaries returns an NSDictionary, and since NSDictionary overrides the -valueForKey: method, you can turn the [0] bit into a key path, by turning it into a literal string:
$player.currencyDictionaries.'0'.earned

How can I check for a certain suffix in my string?

I got a list of strings. And I want to check for every string in there. Sometimes, a string can have the suffix _anim(X) where X is an integer. If such string has that kind of suffix, I need to check for all other strings that have the same "base" (the base being the part without suffix) and finally group such strings and send them to my function.
So, given the next list:
Man_anim(1)
Woman
Man_anim(3)
Man_anim(2)
My code would discover the base Man has a special suffix, and will then generate a new list grouping all Man objects and arrange them depending on the value inside parenthesis. The code is supposed to return
Man_anim(1)
Man_anim(2)
Man_anim(3)
And send such list to my function for further processing.
My problem is, how can I check for the existence of such suffix, and afterwards, check for the value inside parenthesis?
If you know that the suffix is going to be _anim(X) every time (obviously, with X varying) then you can use a regular expression:
Regex.IsMatch(value, #"_anim\(\d+\)$")
If the suffix isn't at least moderately consistent, then you'll have to look into data structures, like Suffix Trees, which you can use to determine common structures in strings.