Unable to implement regex for string in line starts with ? and ends with ;
appended with single quotes or double quotes.
for example:
?abcdef;
'?abcdef;'
"?abcdef;"
I tried a lot, like this "^\\?([^;]+)\\;$" but it did not work.
Test code snippet:
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegexTest {
public static void main(final String[] args) {
final String text = "This is param-start ?abcdef; param-end";
final String patternString = "(['\"]?)\\?.*;\\1";
final Pattern pattern = Pattern.compile(patternString, Pattern.CASE_INSENSITIVE);
final Matcher matcher = pattern.matcher(text);
System.out.println("lookingAt = " + matcher.lookingAt());
System.out.println("matches = " + matcher.matches());
}
}
