View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dana DeLouis Dana DeLouis is offline
external usenet poster
 
Posts: 947
Default Regular expressions

Here's one way. There may be a better way to test for a character other
than \D\d, but I don't know it off hand. Maybe someone can jump in with a
better test.

Sub TestIt()
Debug.Print GetString("handStatus[0] = 'I need this data' ")
End Sub

Function GetString(s As String)
Dim re
Set re = New RegExp

re.IgnoreCase = True
re.Global = True
re.MultiLine = True
re.Pattern = "'([\D|\d]+)'"

If re.test(s) Then
GetString = re.Execute(s)(0).SubMatches(0)
End If
End Function

--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"JeffMelton" wrote in message
oups.com...
I've been working with some html and am trying to use regular
expressions to get a value. Here is what I'm looking for
"handStatus[0] = '(I need this data)';"

I need to find the part that says I need this data, the () are not part
of the string but the ' are. This is what I've tried, but I've never
really worked with Regexp, could somebody tell me what I need to fix?

Set RegEx = New RegExp
anyStr = myIE.document.body.innerText
RegEx.Pattern = "handStatus[0] = '(\w)';"
RegEx.IgnoreCase = True
RegEx.Global = True ' Set global applicability.
Set match = RegEx.Execute(anyStr) ' Execute search.
MsgBox (match.Value)

Thanks