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 4331940
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:11:06+00:00 2026-05-21T10:11:06+00:00

I’m trying to query a database of Book titles based on the first letter

  • 0

I’m trying to query a database of Book titles based on the first letter of the title. However, I want to ignore common words such as “The” and “A”.

So when searching for books that start with the letter “T”

"The Adventures of Huck Finn" - would NOT be matched
"Transformation of a Runner" - would be matched

I’m not very experienced with REGEX, but this is what I have so far (where $first_letter could equal ‘t’)

... WHERE title = '^[(a )(the )]*[$first_letter]' ...

This successfully matches book titles that start with a particular letter even after the words “A” or “The”, but doesn’t ignore those words. So if $first_letter=’t’, it would match BOTH books mentioned above.

I’ve tried googling it, but haven’t found any solutions. Any help would be greatly appreciated.

Thanks in advance.

Kevin

  • 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-21T10:11:07+00:00Added an answer on May 21, 2026 at 10:11 am

    The regular expression you’ve written isn’t valid. []s are used to denote what is called a character class. Everything you enter between the brackets (with some characters potentially needing to be escaped, such as the literal characters [ and ]) is treated as standing-in for a single character.

    edit After re-reading my answer, I realized lookaround wasn’t a good way to approach this.

    The functionality you’re groping for is called negative lookahead, negative lookbehind, or some similar variant. I’m unsure whether MySQL’s regex flavor supports it, but I don’t think it would be a good fit for this problem.

    Alternatively, you could do a regex that looks like this:

    ^((a|the|of|and) )?[letter of interest]
    

    The breakdown:

    • There are two groups
      • The inner-most group looks for instances of words you want to ignore
      • The outer-most group just adds a space to the end of that
    • The ? asserts that there could be 0 or 1 instances of this group

    You’ll have to do the legwork of translating this into MySQL regex syntax yourself. My apologies.

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

Sidebar

Related Questions

Let's say I'm outputting a post title and in our database, it's Hello Y’all
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I have a small JavaScript validation script that validates inputs based on Regex. I
I am trying to render a haml file in a javascript response like so:

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.