Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Replace character expression
Message
 
 
To
09/07/2010 17:53:23
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01471799
Message ID:
01472120
Views:
59
This message has been marked as a message which has helped to the initial question of the thread.
Try
lcStr = "a [1-2] b [2-3] c [3-4] d [4-5] e [5-6] ... [9-10]"

loRegEx = NEWOBJECT("VBScript.RegExp")
loRegEx.Pattern = "\[([1-9])-([1-9])\]"
loRegEx.Global = .T.
lcNewStr = loRegEx.Replace(lcStr, "[0$1-0$2]")

loRegEx.Pattern = "\[([1-9])-([1-9]\d)\]"
lcNewStr = loRegEx.Replace(lcNewStr, "[0$1-$2]")


? lcStr
? lcNewStr
>
>if it's not too much of a strain on the imposition, how would i change this formula to catch
>lcStr = "a [1-2] b [2-3] c [3-4] d [4-5] e [5-6] ... [9-10]" && in latter case 10 would not be altered
>
>such that [1-2] would be changed to [01-02]
>k
>
>lcStr = "a [1] b [2] c [3] d [4] e [5] ... [9]"
>loRegEx = NEWOBJECT("VBScript.RegExp")
>loRegEx.Pattern = "\[([1-9])\]"
>loRegEx.Global = .T.
>lcNewStr = loRegEx.Replace(lcStr, "[0$1]")
>
>? lcStr
>? lcNewStr
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform