Re: Extract Numbers from Memo field
- From: "Lyle Fairfield" <lylefairfield@xxxxxxx>
- Date: 17 Jul 2006 06:26:19 -0700
RoyVidar wrote:
Function rvsSixDigits(ByVal v_strIn As String) As Variant
Dim re As Object
Dim SDNMatches As Object
Dim SDN As Object
Dim SDNS As String
Set re = CreateObject("vbscript.regexp")
With re
.Global = True
.Pattern = "(^|\D)(\d{6})(\D|$)"
Set SDNMatches = .Execute(v_strIn)
For Each SDN In SDNMatches
SDNS = SDNS & "," & SDN.SubMatches(1)
Next SDN
SDNS = Replace(SDNS, ",", "", , 1)
End With
rvsSixDigits = Split(SDNS, ",")
End Function
Very nice; I didn't know VBScript's RegExp had submatches, and have
never been successful in VBS with using $n.
I think if one wanted an example of why we strive for elegant solutions
one might read this thread.
.
- References:
- Extract Numbers from Memo field
- From: Dave
- Re: Extract Numbers from Memo field
- From: Lyle Fairfield
- Re: Extract Numbers from Memo field
- From: Lyle Fairfield
- Re: Extract Numbers from Memo field
- From: RoyVidar
- Extract Numbers from Memo field
- Prev by Date: Re: ODBC Call -- Failed
- Next by Date: Is it wise to upgrade?
- Previous by thread: Re: Extract Numbers from Memo field
- Next by thread: typing a VIN number into a combo box VS selecting a value from list
- Index(es):