Re: Use of Like to extract data
- From: rve_52@xxxxxxxxxxx
- Date: 11 Mar 2007 08:53:45 -0700
Thank you both for your help.
I went through all of the data tyhat I have to use, and this is the
patter
A ###.
i.e. an optional Alpha Character followed by a space. They always
come together, or are absent together. Then up to 3 numeric
characters then a period.
Examples would be
F 1.
F 001.
676.
1.
14.
J 12.
Ron example works nicely and does what I need, however could you tell
me how to expand on your sPatter to deal with the examples I used
above? I've never worked with this type of matching before, so I'm
not sure how to change the pattern your showed me.
Thanks
b
Sub test()
Dim s(3) As String
Dim i As Long
s(0) = "abc12.xy"
s(1) = "123.abc"
s(2) = "12ab456.xyz"
s(3) = "12345." 'not sure what you want here
Dim oRegex As RegExp
Dim oMatch As Match
Dim colmatches As MatchCollection
Const sPattern As String = "\d{1,3}(?=\.)"
Set oRegex = New RegExp
oRegex.Pattern = sPattern
oRegex.Global = True
For i = 0 To UBound(s)
If oRegex.test(s(i)) = True Then
Set colmatches = oRegex.Execute(s(i))
Debug.Print colmatches(0)
End If
Next i
End Sub
==============================
--ron- Hide quoted text -
- Show quoted text -
.
- Follow-Ups:
- Re: Use of Like to extract data
- From: Ron Rosenfeld
- Re: Use of Like to extract data
- From: KL
- Re: Use of Like to extract data
- References:
- Use of Like to extract data
- From: rve_52
- Re: Use of Like to extract data
- From: Ron Rosenfeld
- Use of Like to extract data
- Prev by Date: Re: Track color change
- Next by Date: Re: How do I Create 'ragged' arrays in Excel VBA?
- Previous by thread: Re: Use of Like to extract data
- Next by thread: Re: Use of Like to extract data
- Index(es):
Relevant Pages
|