INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

LIKE with wildcard where the string being matched ends with a non-digit

LIKE with wildcard where the string being matched ends with a non-digit

LIKE with wildcard where the string being matched ends with a non-digit

(OP)
How can I write a query using LIKE with a wildcard where the string being matched ends with a non-digit?

For instance, I need a match on "LIKE 'Stale Ticket #13530%'" which will match the following values:

Stale Ticket #13530
Stale Ticket #13530 | Notice 4

But not these values:

Stale Ticket #135305
Stale Ticket #1353076

In other words, "13530" should only be matched if it's not followed by another digit

RE: LIKE with wildcard where the string being matched ends with a non-digit

Hi

Use regexp instead :

CODE --> MySQL ( fragment )

ticket regexp '^Stale Ticket #13530([^[:digit:]]|$)' 

Feherke.
feherke.ga

RE: LIKE with wildcard where the string being matched ends with a non-digit

(OP)
Perfect, thanks feherke. I figured some kind of regex voodoo would do the trick, but I've never had any success trying to learn regular expressions.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close