String matching and replace in Java -



String matching and replace in Java -

i have string this:

string = "barbara liskov (born barbara jane huberman on nov 7, 1939" +" in california) computer scientist.[2] ford" +" professor of engineering science in mit school of engineering's electrical" +" engineering science , computer science section , institute professor" +" @ massachusetts institute of technology.[3]";

i replace of these elements: [1], [2], [3], etcetera, blank space.

i tried with:

if (a.matches("([){1}\\d(]){1}")) { = a.replace(""); }

but not work!

your pattern wrong.

try example:

string input = "barbara liskov (born barbara jane huberman on nov 7, 1939 in california) " + "is computer scientist.[2] ford professor of engineering science " + "in mit school of engineering's electrical engineering science , computer " + "science section , institute professor @ massachusetts institute " + "of technology.[3]"; // | escaped opening square bracket // | | digit // | | | escaped closing square bracket // | | | | replace 1 space system.out.println(input.replaceall("\\[\\d+\\]", " "));

output (newlines added clarity)

class="lang-none prettyprint-override">barbara liskov (born barbara jane huberman on nov 7, 1939 in california) computer scientist. ford professor of engineering science in mit school of engineering's electrical engineering science , computer science section , institute professor @ massachusetts institute of technology.

java string match string-matching

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -