Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 435989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:25:55+00:00 2026-05-12T20:25:55+00:00

I have a to match a field in MySQL, for which I thought I

  • 0

I have a to match a field in MySQL, for which I thought I could use a regular expression, but it appears that MySQL doesn’t have the functionality I need to do the job. Here’s the scenario:

I have a variable in PHP called $url. Let’s say this variable is set as the string “/article/my-article/page/2”. I also have a table of URLs in MySQL from which I would like to pull content. The URLs stored in my table, however, include wildcards.

Previously, I had this set up so that the value stored in the table looked like this: “/article/%/page/%”.

With that configuration, I could just run:

SELECT * FROM urls WHERE '$url' LIKE url

And this would match, which is the desired functionality.

What I’d like to do now, is allow a more advanced wildcard, such that instead of “/article/%/page/%”, my MySQL data could be “/article/{{slug}}/page/{{page_no}}”.

I want to create a SQL query that will match this data, using the same $url input. LIKE is no longer the correct comparison, since I’m not using the built-in “%” wildcard, but rather {{.*}}. Any ideas how to accomplish this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T20:25:55+00:00Added an answer on May 12, 2026 at 8:25 pm

    I’ve found a solution. It’s not ideal, but I’ll put it in here in case a pure SQL solution never surfaces. I can leave the url field in MySQL equal to “/articles/%/page/%” and add another field called variables that stores a list of variable names to be used. That way I can use my original query, then replace the “%” characters in the return value with “{{variable}}” in PHP with sprintf after I’ve retrieved the data.

    Still, I’d like to see this solved in SQL if possible, since I think the concept is valuable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a Regular Expression (using php) below; which must match ALL terms
In my mysql table I have a field which is a 4 letter Myers-Briggs
$value = 'http://www.mydomain.com/this-is-page-one' I have a field in my mysql table called urls which
I have a MySQL table with a 'tags' field, which is using a FULLTEXT
I have two fields that I'd like to match. (already done the validation functions
I have to match two hashtable, but its keys does not match. So i
Is this Regex correct if I have to match a string which is atleast
guys i have arrays in which i have to match this kind of text
I have a collection of objects, each has a field called fingerprint which contains
So apparently if a Mysql table's fulltext index contains a keyword that appears in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.