View Single Post
Old 10-03-2012, 11:08 PM   PM User | #1
billatl
New Coder

 
Join Date: Oct 2009
Posts: 51
Thanks: 6
Thanked 0 Times in 0 Posts
billatl is an unknown quantity at this point
Using String "Matches" with Variable

Hello,

I'm trying to use matches to find a string within a string, but running into trouble using it with a variable. Concatenating the string doesn't seem to be the answer - what is the correct syntax?

Code:
String queryString = request.getQueryString();
for(String value: mvalues ) {
  if (value.matches("(?i).*" + queryString + ".*")) {
	out.println(value + " is a match!");  
  }  
}
billatl is offline   Reply With Quote