CodeEsthete
11/16/2018 - 9:59 PM

Extract sub string by patter

This pattern extract data from the string. Spaces around = are optional in pattern.

String mydata = "some string with videochat = 'the data i want' inside";
Pattern pattern = Pattern.compile("videochat\\s?=\\s?'(.*?)'");
Matcher matcher = pattern.matcher(mydata);
if (matcher.find()) {
    System.out.println(matcher.group(1));
}