This works to make all letters in a string that are connected to digits uppercase. For example makes bb30 go to BB30 or 30bb go to 30BB.
SubstrUpperCase := RegExReplace(SubstrUpperCase, "\b([a-zA-Z]*)(\d+)([a-zA-Z]*)\b", "$U1$2$U3")
I now need to make bb-30 go to BB-30 or 30-bb go to 30-BB.
I tried Several variations of this
SubstrUpperCase := RegExReplace(SubstrUpperCase, "\b([a-zA-Z]*)(\W+)(\d+)(\W+)([a-zA-Z]*)\b", "$U1$2$U3")
But nothing is working. Thanks
Need to modify a string
Re: Need to modify a string
Code: Select all
MsgBox % RegExReplace("bb30 30bb bb-30 30-bb bb30bb bb-30-bb", "\b([a-zA-Z]*)(\W*)(\d+)(\W*)([a-zA-Z]*)\b", "$U1$2$3$4$U5")
Re: Need to modify a string
Hello, It now seems the solution from swagfag was not just what I needed. If I start with this string "This 456-mh-666-g-87 Part" I need to end up with this "This 456-MH-666-G-87 Part" and I am getting this "THIS 456-MH-666-G-87 PART". I just want letters that are attached to numbers with "-" to be uppercase. I'm needing "This" and "Part" to just be left alone because they are not connected with "-". thanks
Re: Need to modify a string
This might work, using look-ahead/look-behind assertions.
Code: Select all
q::
vText := "I now need to make bb-30 go to BB-30 or 30-bb go to 30-BB."
vText := "This 456-mh-666-g-87 Part"
vText := RegExReplace(vText, "[A-Za-z]+(?=-\d)", "$U0")
vText := RegExReplace(vText, "\d-\K([A-Za-z]+)", "$U0")
MsgBox, % vText
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Need to modify a string
Thanks jeeswg... That seems to have cleaned this up.
Who is online
Users browsing this forum: LeafyWater and 131 guests