I want to concatenate a regex and a string and want to compare the resultant string with another string.How can I do that in java?
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegexMatching {
public static void main(String aaa[])
{
String testStr="anjaneyPANDEY";
String regEx = "([A-Z])";
Pattern pattern = Pattern.compile(regEx);
Matcher matcher = pattern.matcher(testStr);
String st="anjaney"+regEx;
if(testStr.matches(st))
System.out.println("YES");
else System.out.println("NO");
}
}