Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regular Expression in String

 
paul pavlentey
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic