locked
use regular expressions in vfp RRS feed

  • Question

  • HI all,

    I am using vfp and I want to search for some text using regular expressions.

    StringValue = "some text here <!-- some other text"

    I want to search <!-- characters in the above string using regular expressions. Can any body help?

    regards

    Wednesday, October 19, 2011 9:19 AM

Answers

  •  

    loRegExp = CREATEOBJECT("VBScript.Regexp")

    loRegExp.PATTERN = "<!--"

    loRegExp.IgnoreCase = .T.

    loRegExp.GLOBAL = .T.

    loMatches = loRegExp.Execute("some text here <!-- some other text")

    lnMatches = loMatches.Count   && Number of matches

    FOR lnMatch = 0 TO (lnMatches - 1)

          ?loMatches.Item(lnMatch).FirstIndex && Start position

    ENDFOR

     

    • Marked as answer by Creative_Pro Wednesday, October 19, 2011 10:18 AM
    Wednesday, October 19, 2011 9:44 AM

All replies

  •  

    loRegExp = CREATEOBJECT("VBScript.Regexp")

    loRegExp.PATTERN = "<!--"

    loRegExp.IgnoreCase = .T.

    loRegExp.GLOBAL = .T.

    loMatches = loRegExp.Execute("some text here <!-- some other text")

    lnMatches = loMatches.Count   && Number of matches

    FOR lnMatch = 0 TO (lnMatches - 1)

          ?loMatches.Item(lnMatch).FirstIndex && Start position

    ENDFOR

     

    • Marked as answer by Creative_Pro Wednesday, October 19, 2011 10:18 AM
    Wednesday, October 19, 2011 9:44 AM
  • Hi,

    there's a great contrib, by Gregory Adam, on that abstract here : http://www.atoutfox.org/modules/articles/pdf/0000000748.pdf

     


    Michel LEVY
    Wednesday, October 19, 2011 9:49 AM
  • Hey

    Thanks for the replies.

    This is very helpful

    regards

    Wednesday, October 19, 2011 10:18 AM