Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am very new with regexp. I would like to know the pattern defined by this regexp :

^[A-Za-z]{2}[1-9]{2}.*

It starts with 2 alphabetic characters then 2 numeric characters then a . and * which is for 0 or several occurences of the last characters.

What I don't understand is what is the dot used for?

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

You should refer to this

^[A-Za-z]{2}[1-9]{2}.*

Regular expression visualization

Debuggex Demo

It's gold mine when it comes to explain regexp. ^ stands for beginning of the line
[A-Z a-z] stands for any letter in the alphabet upper or lower case
[1-9] stands for a number between 1 and 9 included
. as mention stands for any char except end of line depending of your regexp engine

Then you need to read the graph from left to right and respect the loops indication to understand what matches and what not matches.

share|improve this answer
add comment

^ indicates the beginning of line; followed by two alphabetic characters (uppercase or lowercase), followed by two numeric characters in the range 1-9, followed by any number of characters.

share|improve this answer
    
And what does the dot stand for ? –  user1058398 Feb 27 at 14:05
    
. means "match any character". So, .* means "match any number of occurrences, including zero, of any character" –  D_Bye Feb 27 at 14:06
add comment

. matches any single character in regex

Please refer this

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.