Reputation: 1871
$res = $db->prepare("SELECT user_id FROM sam_users WHERE user_name RLIKE ?");
$res->execute(array($login.'[[:digit:]]*'));
I need a regex that returns all the accounts that match $login, or $login followed by one or more digits, but not followed by alpha values.
example In my database I got account bla, bla2, bla3 and blabla
if I do a search on bla, i want to get back: bla bla2 bla3 BUT NOT blabla
My current code also returns blabla :/
Upvotes: 1
Views: 516
Reputation: 367
I think this is the regular expression you should be using:
bla[0-9]*$
Upvotes: 0
Reputation: 56357
You can try in this way
SELECT user_id FROM sam_users WHERE user_name regexp '^bla[0-9]*$'
Upvotes: 1