Search code examples
mysqlsqlregexquotes

MYSQL: REGEXP single quotation matching


I am having a trouble matching a string in a MySQL-query with the following regex:

I want it to match to this string: "Rue de l' Harmonie"

SELECT
  id,
  street_name
FROM
  street_names
WHERE
  street_name REGEXP '^(rue[a-z]+[[:blank:]])((du|de|la|des|d[\']|l[\'])[[:blank:]])*[[:<:]]HARMONIE$'

Anybody can give me a hint?


Solution

  • At the beginning:

    ^(rue[a-z]+
    

    The + requires that there be at least one a-z char directly following rue. You probably want *.