This is a discussion on How to use Regular expression in Java? within the Java Programming forums, part of the Software Development category; Can any body tell me how to use Regular expression in java?...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Can any body tell me how to use Regular expression in java?
__________________ S.VinothkumaR Behind me is infinite power, Before me is Endless Possibility, Around me is Boundless Opportunity, Why should I fear! |
| Sponsored Links |
| |||
| JDK versions 1.4.0 and later have comprehensive support for regular expressions through the standard java.util.regex package. Because Java lacked a regex package for so long, there are also many 3rd party regex packages available for Java. I will only discuss Sun's regex library that is now part of the JDK. Its quality is excellent, better than most of the 3rd party packages. Unless you need to support older versions of the JDK, the java.util.regex package is the way to go. Regular expressions are a way to describe a set of strings based on common characteristics shared by each string in the set (ie. by pattern matching). They can be used as a tool to search, edit or manipulate text or data. One common use is validation of data entry strings. All classes related to regular expressions are found in the java.util.regex package which must be imported. Java regular expression patterns use a syntax similar to the one used by perl. The best reference is found at sun.com. Simple examples of the use of regular expressions are: Code: Pattern p = Pattern.compile("a*b");
Matcher m = p.matcher("aaaaab");
boolean b = m.matches(); Code: boolean b = Pattern.matches("a*b", "aaaaab"); |
| |||
| The article is a little too short. Actually If I want to match any '\'? Should I write "\\" or "\\\" or "\\\\"?
__________________ Krishnakumar.S Beware of Everything -that is un true; stick to the Truth shall succeed slowly but steadily |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| what is regular expression? | saravanan | PHP Programming | 8 | 03-28-2008 06:12 AM |
| Regular expression tips & tricks | prasath | Database Support | 8 | 09-24-2007 09:55 PM |
| Regular expression | Sathish Kumar | C# Programming | 23 | 09-10-2007 06:00 AM |
| Can any one give regular expression for this string? | raj | PHP Programming | 1 | 07-24-2007 11:42 PM |
| Regular expression | vadivelanvaidyanathan | Perl | 0 | 07-15-2007 06:21 PM |