Find in string
BlitzMax Forums/BlitzMax Programming/Find in string
| ||
Is there a function that will look through a string and if it contains another string it will return true. For example, lets say you had a string Global Str$ = "My name is Bob." and you want to know if it contains the string "Bob". How would you do that. Thanks |
| ||
Instr$() |
| ||
Wow, that's it? Great, I forgot about that function, thanks. |
| ||
Str.Contains( "Bob" ) Contains Returns true if a string contains subString |
| ||
Oh, I think that looks more like it. Thanks jsp. |
| ||
But it can't find the function Contains(). |
| ||
Global Str$ = "My name is Bob." Print Str.Contains( "Bob" ) Print Str.Contains( "BMAX" ) run it to see the result EDIT: And it is a Method not a Function |
| ||
OOP, errr. Thanks though. |
| ||
Take a look in the help at Language->Strings this lists all the methods available for strings. |
| ||
Dont forget the find method if you want to know where the sub string is: Local str:String = "My Name is Bob" Local pos:Int = str.Find("Name") |
| ||
How could I the Character at a Position of a String? |
| ||
How could I <????> the Character at a Position of a String? One vital word missing from your question. Anyway, look for right$, left$, mid$ if the missing word is 'find'. |
| ||
Sorry, yes I meant find. What is the syntax of those commands? I need to return a single character. |
| ||
Local str$ = "hello" Print Chr$(str$[4]) '..or.. Print str$[4..5] |
| ||
What is the syntax of those commands? Type, for example, 'right$' in the IDE and press F1 for syntax. Press F1 again for the command reference. |