Problem with matches?

Post your questions and help other users.

Moderator: Martin

Post Reply
magl
Posts: 3
Joined: 23 Aug 2013 13:04

Problem with matches?

Post by magl » 09 Mar 2017 20:33

matches("121345", "\\d{3}.*")

Returns false?

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Problem with matches?

Post by Martin » 09 Mar 2017 21:29

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

magl
Posts: 3
Joined: 23 Aug 2013 13:04

Re: Problem with matches?

Post by magl » 10 Mar 2017 13:23

Oh god! Thanks a lot. Sometimes one misses the obvious.

Post Reply