Page 1 of 1

Problem with matches?

Posted: 09 Mar 2017 20:33
by magl
matches("121345", "\\d{3}.*")

Returns false?

Re: Problem with matches?

Posted: 09 Mar 2017 21:29
by Martin
Hi,

Curly braces within a string with double quotes are replaced by the variable or calculated value so your effectively executing this:
matches("121345", "\\d3.*")

You can avoid this by using single quotes:
matches("121345", '\\d{3}.*')

Regards,
Martin

Re: Problem with matches?

Posted: 10 Mar 2017 13:23
by magl
Oh god! Thanks a lot. Sometimes one misses the obvious.