This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes Regular Expression in String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Regular Expression in String" Watch "Regular Expression in String" New topic
Author

Regular Expression in String

paul pavlentey
Greenhorn

Joined: Jul 20, 2006
Posts: 10
How regular expression string should look like to find the match in the string of word "amp". I want to use method String.matches(String regex).

Thank you in advance.
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
If you want the word amp (i.e. the regular expression doesnt match the amp in stamp or lamp) the you would use:

boolean match = myString.matches("\\bamp\\b");
[ August 28, 2006: Message edited by: Garrett Rowe ]

Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regular Expression in String
 
Similar Threads
How can I add error handling facilities to this code?
String replacement
List to String
to read lines inside brackets
Regular expression for valid xml