Does a RegEx Pattern need to be modified to be used with SQL in MySql? -


i'am trying write select-statement retrieve list of usernames database. pattern is: /placeholder\d+/ig , tested , can confirm working properly. i'am trying retrieve every placeholder in table.

i tried escape \ after placeholder.

my sql-statement is: select * table (name regex '/placeholder\d+/ig') ... tried different variations backticks, etc or like instead of regexbut likeonly has % , _ wildcard.

does regex pattern needs modified in order work mysql?

unlike scripting languages, mysql not using preg library regular expression matching.

so yes, need modify regex make work in mysql:

select * table name regexp 'placeholder[0-9]+' 

or

select * table name regexp 'placeholder[[:digit:]]+' 

there no short-hand character classes \d in mysql. also, not use regex-delimeter ("/../si" ".." in mysql)

read documentation on regular expressions in mysql more information.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -