7
How to recover fields with the following pattern?
a111/1111
or a111_1111
or a111-1111
or a111+1111
where:
a = some letter of the alphabet;
1 = any digit of 1-9;
I rode a Regex
that is working perfectly: (^[a-z]{1})([0-9]{3})(\W)([0-9]{4})
but I can’t apply it to SQL Server, I tried using LIKE as in this question example:
SELECT * FROM Table WHERE Campo like '%(^[a-z]{1})([0-9]{3})(\W)([0-9]{4})%'
or
SELECT * FROM Table WHERE Campo like '%[(^[a-z]{1})([0-9]{3})(\W)([0-9]{4})]%'
but it does not work, there is a way to make a query using a Regex?
The separator is only one of the characters / _ - and +? You used W in the expression.
– José Diz
Is that /W ended up serving, because if it was another number in the place of the special character o ([0-9]{3}) would not give match because it asks only 3 and not 4
– Leonardo Bonetti
So the fifth character is anyone, as long as it’s not a digit?
– José Diz