Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remove Special Characters and White Spaces in a string
#1
I have a string say !@#$%%^&ME and Bobby ! MckGee#@$%^. I want to strip all of the special characters and white spaces out. In python this line of code would do it re.sub(r'((?![a-zA-Z0-9]).)+', '', line) which uses regular expressions. I cannot seem to get this to work in QM with findrx or replacerx. I know I am doing something wrong, This is the Regex that is key ((?![a-zA-Z0-9]).)+'

Anybody know how to do this?


edit

this is what I would expect back
MEandBobbyMckGee
#2
Try this:
Macro Macro75
Code:
Copy      Help
str s="!@#$%%^&ME and Bobby ! MckGee#@$%^."
out "Before = %s" s
str regex="((?![a-zA-Z0-9]).)+"
s.replacerx(regex "" 8)
out "After = %s" s
#3
Thanks I thought I tried that, obviously not.


Forum Jump:


Users browsing this thread: 1 Guest(s)