Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RegEx
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
RegEx
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01555501
Message ID:
01555501
Views:
88
Hi everybody,

I've figured out the first part:
lcString = 'abc1234567890123456fd'

loRegExp = CREATEOBJECT("VBScript.Regexp")
 
loRegExp.PATTERN = "\D\d{16}\D*" && search for non digit following by 16 digits
 
loRegExp.IgnoreCase = .T.
 
loRegExp.GLOBAL = .T.
 
loMatches = loRegExp.Execute(lcString)
 
lnMatches = loMatches.Count   && Number of matches
 
FOR lnMatch = 0 TO (lnMatches - 1)
 
      ?loMatches.Item(lnMatch).FirstIndex && Start position
      ?loMatches.Item(lnMatch).value
 
ENDFOR 
I am looking for a way to identify a 16 digit number preceeding by any non-digit character and ending with non-digit character or nothing. The pattern I defined seems to work. However, I need to replace only that 16 digit number with the 16X. I am not sure how to apply Replace command here.

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform