• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Escape Special Character in Mysql Regexp Search

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I need to search for exact match of c++, so escaped it with backslash
and used regexp wordboundries like this

SELECT * FROM tablename j where j.fieldname REGEXP '[[:<:]](C\\+\\+)[:>:]]'
It is not displaying any result. But if i search with this syntax
SELECT * FROM tablename j where j.fieldname REGEXP 'C\\+\\+'
It displays all results other than exact match like VC++ which i dont need.

I guess problem with escape ++ and regexp exact match. Please suggest me a solution for this.

Thanks in advance,
Shreya.
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about:

SELECT * FROM tablename j where j.fieldname REGEXP '^C\\+\\+$'

The '^' matches start-of-expression, and '$' matches end-of-expression.
 
shreya vinay
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thank you so much for the query. It works well for c++ but it is not working for some words like .net, c#. i need exact match for this also.can you please suggest a solution for these words?

Best Regards,
Shreya.
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The chances of a regex for .c++ matching .net are not very good. Suggest you write what you think would match, please.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic