This code uses regexp to extract a string, in this case a domain without the dot com. I will eventually use this type of code to extract a large string (newsstory) from an even longer string (source of webpage)
1. is there a way to get at the submatches without the for/endfor loops as I dont know how to pass the (0).SubMatches(0) via vfp directly but can get at them with the for/endfor loops
2. is there a better approach to extracting a string from within a larger string using only vfp
thanks in advance from a confused wjwjr as these regexp make my head hurt a bit!
This old world keeps spinning round - It's a wonder tall trees ain't layin' down
1. is there a way to get at the submatches without the for/endfor loops as I dont know how to pass the (0).SubMatches(0) via vfp directly but can get at them with the for/endfor loops
2. is there a better approach to extracting a string from within a larger string using only vfp
Code:
LOCAL RegEx, strTemp
RegEx = CREATEOBJECT("VBScript.RegExp")
RegEx.Pattern = "@(\w+)\."
Regex.Global = .t.
RegEx.IgnoreCase = .t.
strTemp = "emailaddress@domain.com"
oMatches = RegEx.Execute(strTemp)
FOR EACH thing IN oMatches
FOR EACH foo IN thing.submatches
?foo &&returns "domain"
ENDFOR
ENDFOR
*!* vbscript code
*!* Dim RegEx : Set RegEx = New RegExp
*!* RegEx.Pattern = "@(\w+)\."
*!* RegEx.Global = True
*!* RegEx.IgnoreCase = True
*!* Dim strTemp : strTemp = "anyaddress@anydoamin.com"
*!* -> WScript.Echo RegEx.Execute(strTemp) (0).SubMatches(0) <-
This old world keeps spinning round - It's a wonder tall trees ain't layin' down