dimanche 22 mars 2015

Trailing and Preceding Apostrophes



I've already asked a similar question before but I'd like to know if there is a regular expression to parse a string such that number and strings are extracted ignoring all punctuation but allowing a single apostrophe for each word whether it at the beginning middle or end.



String problem = "'Cause I''m lo#o@kin' t%o ext!r$act a^ll 8 su*bs(tr]i{ngs.";

String[] solve = {"'Cause", "I'm", "lookin'", "to", "extract", "all", "8", "substrings"};


Basically, I want to extract numbers and words with complete disregard to punctuation except single apostrophes. I know how to get words and strings but I can't seem to figure out this tricky part.


Notice that I'm contains only one apostrophe even with two in between.




Aucun commentaire:

Enregistrer un commentaire