Help with Regexp, please
On Sat, 1 May 2010 13:41:03 -0700 (PDT), Raj wrote:
To clarify, the regex should return " Raffles Traders" from the string
below:
NRK2D 986123456789312 Raffles Traders
The regex (\d{15,16})([\s\S]*) is returning "986123456789312 Raffles
Traders"
Regards,
Raj
Obviously, you are not doing what I suggested which was to return the *SECOND*
matching group. You are returning the ENTIRE match. Here's an example as to
returning the *SECOND* match using VBA:
===============================
Option Explicit
Function Part2(s As String) As String
Dim re As Object, mc As Object
Set re = CreateObject("vbscript.regexp")
re.Pattern = "(\d{15,16})([\s\S]*)"
If re.test(s) = True Then
Set mc = re.Execute(s)
Part2 = mc(0).submatches(1)
End If
End Function
==================================
--ron
|