0

Which is the Regex for these symbols?

-, , %, /, ., "", «», '', ', <, >, &, :, (, ), !, ^, *

Ι need to Replace them all with Space.

2 Answers 2

2

Try

String r = t.replaceAll('[-%/.<>&:]',' '); 

// Put all your symbols here.

Example:

String t = 'I-am%Noor/who/are:you<I>am';
String r = t.replaceAll('[-_%/."<>&:()!/*/^]',' ');
System.Debug(r);

Output:

I am Noor who are you I am
1
1

Just adding another option here: you can utilize some great playground tools to figure it our or test out your regex before putting it into your code.

https://regexr.com/

and then a great resource for learning regex as well

https://regexone.com/

1
  • Awesome! Thanks Kris:) Commented Nov 2, 2019 at 8:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .