Thursday, February 11, 2010

Splitting stings and wildcards in VB.NET?

I'm working on a text based RPG with a friend and in order to get things to work properly I need to find a way to divide the text the user puts in into parts.





For example:


User inputs ';use potion';. I need to be able to split the string into 2 parts, the action (use) and the target (potion).





I also need a wildcard type thing.





For example:


If strInput = ';use'; %26amp; (anything else) Then...





Any help is greatly appreciated.Splitting stings and wildcards in VB.NET?
the string object has a split method on it that you can use, it also has a maximum count on it.. what i would suggest is split the input into 2 elements max similar to myString.split(' ', 2), the 1st word (ie, use, get, look, etc) and then the rest (ie, the key, the blue key, key).

No comments:

Post a Comment