# searching inside a string???????????

Hello everyone, my name is haris and I have recently started to learn basic. Right now a lot of things are looking very very difficult. I have downloaded couple on books on how to use liberty basic. And while every book tells the same function for searching inside a string instr function. I want to to know is it possible to search for two strings or numbers inside a string.

Here is a small example:
Print "what is the string?"
Input string\$
Pos1 = instr\$(string\$,"a",1)
Pos2 = instr\$(string\$,"b",1)

I want to know is it possible to search for "a" and "b" in a single function?
Anyhelp will be greatly appreciated.
[code][/code][code][/code]

• Hello haris,

[code]Pos1 = instr\$(string\$,"a",1)[/code]

is optional, and simply means start searching string\$ from the first character.

So if you input the string "Where is my hat?", the value of Pos1 will be 14, since "a" is found at the 14th character position.

[code]Pos2 = instr\$(string\$,"b",1)[/code]

will return Pos2 = 0, since the character "b" has not been found in the
string "Where is my hat?".

Your question is not very clear. The string to be searched for can be any number of characters. So if the input string had been "It's about time too", the following instr() statement will return a value for Pos1 = 6.

[code]Pos1 = instr\$(string\$,"ab",1)[/code]

which is where the string "ab" begins.

To search for two independent strings, you would need to have two instr() statements to find where each began.

hope that helps,

Graham