ehart12
asked on
Rereplace, remove all special characters except space
I have descriptions of items that I need to remove ALL characters that are not letters or numbers, and I would like to preserve spaces. I am new to expressions and on overload since I cannot seem to come up with the magical solution...
REReplace(str, "[^0-9a-zA-Z_]", "", "ALL")
Any suggestions?
Thank you,
Eric
REReplace(str, "[^0-9a-zA-Z_]", "", "ALL")
Any suggestions?
Thank you,
Eric
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ah! A guru without spectacles <|;-)
ASKER
azadisaryev,
I tried dozens of different combinatioins and "REReplace(str, "[^\w ]", "", "all")" did the trick!
Thank you very much,
Eric
I tried dozens of different combinatioins and "REReplace(str, "[^\w ]", "", "all")" did the trick!
Thank you very much,
Eric
That line was not from me, you see?
My proposal was adding meta char \s which includes also \n and \t to the space character as Azadi stated.
I proposed \s for better readability because tab and new line character do normaly not mess with space in line input fields but do so in textarea fields.
My proposal was adding meta char \s which includes also \n and \t to the space character as Azadi stated.
I proposed \s for better readability because tab and new line character do normaly not mess with space in line input fields but do so in textarea fields.
and it looks like _ is not one of the allowed characters, according to the question...
one of these should do the trick:
REReplace(str, "[^\w ]", "", "all")
REReplace(str, "[^0-9a-zA-Z ]", "", "all")
REReplace(str, "[^[:alnum:] ]", "", "ALL")
Azadi