0

I want to get all lines that according to the pattern xxx.xxx (only) where x is a number from 1 to 9 or any letter

My expression does not work REGEXP '[a-z]{1,3}\.[a-z]{1,3}'

Thx!

UPD: Thx fo all, but does not work! I tryed so

SELECT email, registered, voted, ip, agent
FROM  `voters` 
WHERE member =199
AND DATE_FORMAT( voted,  '%Y-%m-%d' ) <  '2014-09-23'
AND SUBSTRING_INDEX( email,  '@', 1 ) 
REGEXP  '[a-zA-Z1-9]{3}\.[a-zA-Z1-9]{3}'

result:

libsherbakul@...
savelkina_061080@...
dreik_339@...
simauta25@....
suslenkovagtp@...
driamoff@...
anashkina_1966@...
fedotovauliya@...
omsklib@...

UPD 2: Itryed change pattern so '[a-zA-Z1-9]{3}[\.]{1}[a-zA-Z1-9]{3}' RESULT:

regina.zheyli@...
rus.antonin@...
kira.albenina@...
alya.oktya@...
andryushka.gromov.1986@...
inna.festival@...
ilyubaj.baktybaev@...
vika.korotkova.02@...
silina.lika@...
mika.sidorova@...
kharlov.dmitriy@...
toni.gordon.70@...
vasya.ganichev.74@...
fomin.slavick22@...

No good, becouse more than 3 symbols before and after "."

2
  • try [a-zA-Z1-9]{3,}\.[a-zA-Z1-9]{3,} Commented Sep 24, 2014 at 13:08
  • does not work, passes over 3 symbols and few "." Commented Sep 24, 2014 at 13:23

3 Answers 3

1

If you want exactly three letters or digits followed by a dot, followed by exactly three characters with the same conditions and not more before and after then you've got to use

REGEXP '^[a-zA-Z1-9]{3}\.[a-zA-Z1-9]{3}$'

The special characters ^ and $ have this meaning:

character     meaning
----------------------------------------------
    ^         Match the beginning of a string.
    $         Match the end of a string.
Sign up to request clarification or add additional context in comments.

Comments

0

[a-z] matches only lowercase alphabet. You need to specify uppercase, digits 1-9 too.

And the quantifier should be modified. {1-3} matches 1 to 3 times of preceding pattern. Use {3} to match 3 times.

REGEXP  '[a-zA-Z1-9]{3}\.[a-zA-Z1-9]{3}'

Comments

0

should be

[a-zA-Z1-9]{3}\.[a-zA-Z1-9]{3}

to allow 3 only on both sides of period.

and any letter as you said.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.