Tuesday, 15 April 2014

java - Regex Match Word with special character -


I want to see a word in a file that contains dates and percentages and some strings like the different notifications.

Input:

  21-02-2015 The word A22 word B word:  

Result:

  word a word b wordC  

Please help me because I'm new to regex.

Supports the regex implementation of Java, for which this is a textbook used for use.

[\ w & amp; Amp; [^ \ D]] Thus a word corresponds to the character, but not the numbers, it should match the 'special character'.

Thus this code:

  import java.util.regex.Matcher; Import java.util.regex.Pattern; Class test {public static zero main (string ... args) {string input = "21-02-2015 word A22 word be word sea differences"; Matcher matcher = Pattern.compile ("[\\ w and [^ \\ d]] +", pattern. UNICODE_CHARACTER_CLASS) .Misper (input); While (matcher.find ()) {System.out.println (matcher.group ()); }}}  

produces:

  word a word word forwards  

No comments:

Post a Comment