Fastest way to dump special characters?

L

laredotornado

Hello,
I am running Java 1.3 on Solaris. I was hoping there is a nice,
quick, and easy way to take a string that may contain non-alpha numeric
characters (characters that aren't in 0-9, a-z, or A-Z) and return the
same string with all those characters removed. Sure I could do this
with all kinds of for-loops but I figure there is an expert out there
who knows how to do tthis in one line.
I am grateful for that person's advice, - Dave
 
R

Real Gagnon

with all kinds of for-loops but I figure there is an expert out there
who knows how to do tthis in one line.

Try with myString.replaceAll("[^\\p{ASCII}]","");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top