Regular Expression/Escaping syntax in OH2.1

Hey,

Finally getting around to resolving another quibble I encountered up upgrading from 2.0 to 2.1 - the regular expressions in my voice command rule.

If the simple lines below are not commented out:

    var Pattern p = Pattern::compile(".* ([0-9]+)\%.*")
    var Matcher m = p.matcher(command)
    if (m.matches()) {
        newState = new String(m.group(1).trim())
    }

I get [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘helps.rules’ has errors, therefore ignoring it: [583,54]: Invalid escape sequence (valid ones are \b \t \n \f \r " ’ \ )

It used to work fine in 2.0, so what has changed in how I have to wrap/escape characters there?

Can you try to duplicate the backslash in the pattern. I had a similar case today where that helped.

1 Like