java - Finding a regex to return all special characters in a single group -


i want regex return special characters in single group. have made regex return characters using [^a-za_z0-9] 1 not return characters not being letter or digit in single group.

for example if string checked today ~friday() expecting output ~() in 1 string can replace them in 1 go.

but using regex provided getting:

0: [14,15] ~ 0: [21,22] ( 0: [22,23] ) 

try using replaceall method.

below have code find fragments matching normal character sequence , replaces sequence empty string.

    string in = "today ~friday()";     string out = in.replaceall("[a-za-z0-9 ]+", "");      system.out.println(out); 

and result is:

~() 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -