0

Can anyone explain to me why this regex select returns false in PostgreSQL:

select '354902050487064_Gismo3' ~* '\d{15}_\w+'

Tried it on several online regex testers and in matches fine.

Thanks

4
  • Returns true for me in 9.4 Commented Jan 16, 2015 at 12:38
  • It returns true on my 9.4.0 (windows) and 9.3.4 (Linux) installation Commented Jan 16, 2015 at 12:38
  • Ok, got it. In SQL the \ char has to be doubbled, so this expression works: select '354902050487064_Gismo3' ~* '\\d{15}_\\w+' I'm on 6.0.7 64-bit. Thanks for the comments. Commented Jan 16, 2015 at 12:43
  • Correction: I'm on 9.0.7 64-bit of course. Commented Jan 16, 2015 at 12:51

1 Answer 1

1

You have to escape the backslashes:

select '354902050487064_Gismo3' ~* '\\d{15}_\\w+'
Sign up to request clarification or add additional context in comments.

1 Comment

Yes, just found that out and added at comment, but thanks anyway.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.