title: How can I store a regex pattern in a MySQL field and check an input against it?
body: <p>My application is made up of several microservices and I am now working on the API Gateway and Authorization Microservice. Each incoming request will be validated and authorized depending on the user's permissions to perform this activity. An activity is made up of a verb (GET, POST, PUT, DELETE) and an ENDPOINT (/interpretations/q44nAj91aH6nd/)</p>
  
  <p>I have a MySQL table listing all activities and want to match the user's request's endpoint to the matching activity (row) in the table.</p>
  
  <pre><code>    CREATE TABLE `activities` (
        `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
        `url` varchar(255) NOT NULL DEFAULT '',
        `method` varchar(20) NOT NULL DEFAULT 'GET',
        `url_regex` varchar(255) DEFAULT '',
        PRIMARY KEY (`id`)
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  
      INSERT INTO `activities` (`id`, `url`, `method`, `url_regex`)
      VALUES
          (1,'/interpretations/','POST',''),
          (2,'','GET','/interpretations/[a-Z0-9]+/');
  </code></pre>
  
  <p>My question is, how can I match the row 2 for this given request's endpoint: <code>/interpretations/q44nAj91aH6nd/</code> (which should match the regex pattern <code>/interpretations/[a-Z0-9]+/</code>).</p>
  
  <p>When I try the below, it does not work:</p>
  
  <pre><code>SELECT * FROM `activities` WHERE `url_regex` RLIKE "/interpretations/q44nAj91aH6nd/";
  
  # also tried inverting
  
  SELECT * FROM `activities` WHERE "/interpretations/q44nAj91aH6nd/" RLIKE `url_regex`;
  </code></pre>