Hi,
try this code:
This code assumes that the number that has to be extracted from data is always surrounded by two spaces, that is:
-exactly one space before the number, and exactly one space after the number.
try this code:
Code:
Dim strStr
strStr = "37596 AndrzejCzwarty ldskajf@porirker\.plUnlocked2012-11-30 37568 AndrzejDrugi ksjhgjhsdgfui@woeijf\.plLocked2012-11-30 37554 AndrzejPierwszy" &_
" kdjsfhsjd@sdklj\.plLocked2012-11-30 37582 AndrzejTrzeci lsdhflkadjhf@lsdkf\.plUnlocked2012-11-30 " & _
"ZdenekSmetana ldskajf@porirker\.p Locked 88888 " & _
"Jan Kowalski ldskajf@porirker\.p Locked " & _
"Jan Nowak ldskajf@porirker\.p Locked 2012-11-30 "
Dim oRegx
Dim oMatches
Set oRegx = new RegExp
oRegx.pattern = "Locked(\d{4}-\d{2}-\d{2})*\s\d+\s"
oRegx.Global = true
Set oMatches = oRegx.Execute(strStr)
For Each Match in oMatches ' Iterate Matches collection.
strValue = Match.Value
strValue1 = Mid( strValue, inStr( strValue, " " ) + 1 )
MsgBox strValue & " =====> " & strValue1
Next-exactly one space before the number, and exactly one space after the number.

