Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use regex to find text into a string? 1

Status
Not open for further replies.

Paco75

Programmer
Oct 11, 2001
239
US
Hi,

Im searching how to use regular expressions to find text patterns inside a string... like dates. How we do it in visual foxpro?

thanks
 
One option is to invoke the VBScript RegExp class. Something like this:

Code:
oRE = CreateObject("VBScript.RegExp")
oRE.Pattern = "[i]regular expression here[/i]"
lcString = "[i]string to search[/i]"
llResult = oRE.test(lcString)

The last line will return .T. if the expression is found.

You should also take a look at the Regular Expressions Foundation Class - see the VFP Help for details.

Also, Craig Boyd has an FLL to handle Regular Expressions. See:

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Is there a place where i can find complete methods list availiable in VBScript.Regexp?
 
Im asking because i also want to do a substring to retrieve the matched characters. Do you know how to?
 
The full reference of the RegExp Object of VBScript is very small

That's right. It's small, in the sense that it has very few properties and methods. Its functionality comes in the power of the actual regular expressions.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Actually I still think the design of that class is awkward and could be simpler and better explained or better self-explanatory besides the regexp stuff you need to know or learn anyway.

I wished the Global, IgnoreCase and Pattern properties would just be parameters and then it would boil down to three Functions TestPattern (Test), SearchPattern (Execute) and ReplacePattern (Replace).

Bye, Olaf.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top