Page 1 of 1

Visible Characters, Except for Comma and Quote

Posted: Tue May 08, 2018 5:51 pm
by kengrubb
I wanted to do a search and replace of all visible characters (Space thru Tilde), except for Comma and Quote, and replace it with a lowercase x.

I tried to use this, but I missed some things.

[x20-x21x23-x2Bx2D-x7E]

Then I tried this, which also missed some things.

([x20-x21]|[x23-x2B]|[x2D-x7E])

Should I really be using this, which also excludes x?

([x20-x21]|[x23-x77]|[x79-x2B]|[x2D-x7E])

Posted: Tue May 08, 2018 6:05 pm
by MudGuard
for the hex characters, the \ is missing - it should be \x20-\x21 and so on

Posted: Tue May 08, 2018 9:23 pm
by ben_josephs
Or you can enter the characters directly:
[ !#-+\--~]

Or you can separate the range from the exclusions by using negative look-ahead:
(?![,"])[ -~]
or positive look-ahead:
(?=[ -~])[^,"]

But do you really need to restrict this to the range space to tilde? If not, you can simply use
[^,"\n]
This way you have to explicitly exclude newline.