lundi 8 juin 2020

How to find and replace certain string pattern in java

As a result of text extrapolation from PDF's I need to fix some bugs. I need to replace every form of strings like these:

String example="the sun was shin- ing  and the sky bl- ue";

in the form:

String fixxed="the sun was shining  and the sky blue";

I'm not expert in regular expressions, I tried to do so but it's wrong.

String pattern="([\\w])+([\\-])+([\\s])";
String fixxed = text.replaceAll(pattern, "$1");

Aucun commentaire:

Enregistrer un commentaire