string parsing ques

  • Thread starter Thread starter mp
  • Start date Start date
M

mp

Hi
looking for equivalents to vb6 instr and Mid$
been looking through the help but haven't found it yet, will keep looking
but if anyone feels like offering a tip of where to look?

I want to find a substring inside a string, for example
string = "the brown fox"
string2 = .After("the") and .Before ("fox") = "brown"
how to implement After and Before is what i'm looking for

thanks
mark
 
mp said:
I want to find a substring inside a string, for example
string = "the brown fox"
string2 = .After("the") and .Before ("fox") = "brown"
how to implement After and Before is what i'm looking for

See Substring() and IndexOf().

-- Alan
-- cleartopartlycloudy.blogspot.com
 
I want to find a substring inside a string, for example
string = "the brown fox"
string2 = .After("the") and .Before ("fox") = "brown"
how to implement After and Before is what i'm looking for

Take a look at string.Substring.

Michelle
 
Hi
looking for equivalents to vb6 instr and Mid$
been looking through the help but haven't found it yet, will keep looking
but if anyone feels like offering a tip of where to look?

I want to find a substring inside a string, for example
string = "the brown fox"
string2 = .After("the") and .Before ("fox") = "brown"
how to implement After and Before is what i'm looking for

The literal equivalents are, as others have suggested, IndexOf(),
LastIndexOf(), and Substring() for finding the first occurrence of a
string, the last occurrence of a string, and extracting a substring from a
string, respectively (IndexOf() and LastIndexOf() also provide overloads
that let you say where to start the search, so that iterative searches can
find all of a given string).

However, given your elaboration on the question, you are definitely
getting into Regex territory. The Regex class provides a syntax to
describe the relationship you're talking about in a less imperative way,
and then to use that relationship to automatically search for and find the
piece of text you're looking for.

For the exact example, you may still find the String methods concise
enough. But for anything more complicated, you should consider becoming
familiar with the Regex class.

Pete
 
Peter Duniho said:
snip>
However, given your elaboration on the question, you are definitely
getting into Regex territory. The Regex class provides a syntax to
describe the relationship you're talking about in a less imperative way,
and then to use that relationship to automatically search for and find the
piece of text you're looking for.

For the exact example, you may still find the String methods concise
enough. But for anything more complicated, you should consider becoming
familiar with the Regex class.

Pete

after posting i realized that was probably the unfortunate answer :-)
have looked at regex in past and got a headache, guess i have to get over it
:-)
thanks
mark
 
Back
Top