You can use a lookahead only to check if the string matched is before is:
'([^']*)'\\s*(?=\\bis\\b)
See regex demo
Breakdown:
' - single apostrophe ([^']*) - capture group matching 0 or more characters other than ' '\\s* - a single apostrophe and 0 or more whitespace symbols (?=\\bis\\b) - a lookahead making sure there is a whole word is after the current position (after the ' with optional whitespaces)
Java demo:
Pattern ptrn = Pattern.compile("'([^']*)'\\s*(?=\\bis\\b)"); Matcher matcher = ptrn.matcher("RECOVERY: 'XXXXXXXXX' is UP"); if (matcher.find()) { System.out.println(matcher.group(1)); }
UPDATE
I used a lookahead only because you used a non-capturing group in your original regex : (?:is). A non-capturing group that has no quantifier set or any alternation inside seems reduntant and can be omitted. However, people often get misled by the name non-capturing thinking they can exclude the substring matched by this group from the overall match. To check for presence or absence of some text without matching, a lookaround should be used. Thus, I used a lookahead.
Indeed, in the current scenario, there is no need in a lookahead since it makes sense in case you need to match subsequent substrings that start wiyh the same sequence of characters.
So, a better alternative would be
'([^']*)'\s*is\b
Java:
Pattern ptrn = Pattern.compile("'([^']*)'\\s*is\\b");