Connecting Tech Pros Worldwide Forums | Help | Site Map

Get matched String from a string using Regular Expression

dmjpro's Avatar
Lives Here
 
Join Date: Jan 2007
Location: India (West-Bengal)
Posts: 2,451
#1: Oct 7 '09
Expand|Select|Wrap|Line Numbers
  1. Pattern pattern = Pattern.compile("(^MR.)|(^MRS)|(^MRS.)|(^MS)|(^MS.)|(^SIR)|(^SMT.)|(^SRI) *");
  2.  
This is my Regular Expression. When i will find the whether it matches with target string or not using Matcher then can i get the matched string from the target string?

dmjpro's Avatar
Lives Here
 
Join Date: Jan 2007
Location: India (West-Bengal)
Posts: 2,451
#2: Oct 7 '09

re: Get matched String from a string using Regular Expression


Sorry i didn't read the full API.
I found this ..i should have used Matcher.group().
Sorry!
Reply