Strings

  • Thread starter Thread starter Leeper
  • Start date Start date
L

Leeper

Does anyone know a way to search through a string and pull out
specific info? The problem is that this "key" word shows up multiple
times in my string. So I want to come across this word, and capture
the character that is 5 spaces in front of the "key" word. Then repeat
through the string. Any ideas.


Thanks, You guys are the best.
Leeper
 
Leeper said:
Does anyone know a way to search through a string and pull out
specific info? The problem is that this "key" word shows up
multiple times in my string. So I want to come across this word, and
capture the character that is 5 spaces in front of the "key" word.
Then repeat through the string. Any ideas.

Have a look at the methods and properties of the String object.
 
Look up the instr() function.

it works like this:

x=instr("string to search","to")

x would be 8, the location of "to" (returns zero if not found)

if there were multiple instances of "to", you could do this:

start=0
pos=999
do until pos=0
pos=instr(start,"search me I'm a big string to search", "search")
start=pos+1
'do my thing
loop

using the start parameter specifies where to start looking. This way you can
find multiple instances in the same string.
 
* (e-mail address removed) (Leeper) scripsit:
Does anyone know a way to search through a string and pull out
specific info? The problem is that this "key" word shows up multiple
times in my string. So I want to come across this word, and capture
the character that is 5 spaces in front of the "key" word. Then repeat
through the string. Any ideas.

You can use, for example, 'Strings.InStr' or the string's 'IndexOf'
method to search it for a "substring".
 
Back
Top