hello friends!
How can i remove all characters after an number OR and "("
Example
TestOne 71123123
Test Two 71 123123
TestQ (22) 7112 3123
I need remove: 71 123123
Or (22) 7112 3123
Or 71 123123
With results:
TestOne, Test Two and TestQ
Can someone help me?
Remove all charcaters after any number on a string (please)
Re: Remove all charcaters after any number on a string (please)
I found this but it removes Spaces too
Regexreplace(var, "[^[:alpha:]]")
EDIT:
Solved:
I used
it removes all numbers
But i need then to remove () later when i have strings like this:
Regexreplace(var, "[[:digit:]]") will keep "()"
becomes
Then i use
StringReplace, clipboard, clipboard, "()", , All
Is there any better way for
becomes
Directly using one Regexreplace
Regexreplace(var, "[^[:alpha:]]")
EDIT:
Solved:
I used
Code: Select all
Regexreplace(var, "[[:digit:]]")
But i need then to remove () later when i have strings like this:
Code: Select all
Sérgio Teixeira Rangel (22) 981050524
Code: Select all
Sérgio Teixeira Rangel (22) 981050524
Code: Select all
Sérgio Teixeira Rangel ()
StringReplace, clipboard, clipboard, "()", , All
Is there any better way for
Code: Select all
Sérgio Teixeira Rangel (22) 981050524
Code: Select all
Sérgio Teixeira Rangel
Code: Select all
Regexreplace(var, "[[:digit:]]")
Re: Remove all charcaters after any number on a string (please)
I've produced some RegEx code, and some variants. With things like this, there's always the worry that you'll remove some text, that you didn't want removed (even if you're careful, which I've tried to be).
Code: Select all
q:: ;remove text after first digit or opening parenthesis
vText = ;continuation section
(Join`r`n
TestOne 71123123
Test Two 71 123123
TestQ (22) 7112 3123
)
;vOutput := RegExReplace(vText, "m) (\(|\d).*")
;vOutput := RegExReplace(vText, "m) (\(|\d)[ ()\d]*$") ;safer, more restrictive version
vOutput := RegExReplace(vText, "m)[ ()\d]*$") ;simple restrictive version
Clipboard := vOutput
MsgBox, % vOutput
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
Who is online
Users browsing this forum: wilkster and 136 guests