Reputation: 2259
I am having problem with regular expression. I am using regex in query shown as below.
SELECT *
FROM ad
WHERE platform_specific_selection
REGEXP '[\|]{0,1}19[\|]{0,1}'
It gives me somewhat wrong result shown as below.
19|21|
0|19|20|22|
19|
0|919|
I wanted to match exact 19
using regex and I don't want 0|919|
this value in result. Can anybody give me exact regex for the same?
Upvotes: 0
Views: 49
Reputation: 206689
This should work:
select * from t where a REGEXP '(^|[|])19([|]|$)';
(The idea is to allow either |
or start-of-string on the left, and |
or end-of-string on the right.)
Upvotes: 3
Reputation: 1470
Why regex, LIKE is sufficient for this
SELECT *
FROM ad
WHERE platform_specific_selection
LIKE '%|19|%'
Upvotes: 0