? in regex

D

Denis McMahon

I count on Mozilla JavaScript Guide. In the section for ? (question
mark) at
https://developer.mozilla.org/en/JavaScript/Guide/Regular_Expressions ,
? "Matches the preceding character 0 or 1 time." Example:
/e?le?/ matches the 'el' in "angel" and the 'le' in "angle."
How can "l" be matched here? Shouldn't both ?'s match "e" only?

The regex:

/ = start of regex
e? = 0 or 1 "e"
l = 1 "l"
e? = 0 or 1 "e"
/ = end of regex

If you still do not understand, I don't know how to explain in a simpler
way.

Rgds

Denis McMahon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,273
Latest member
DamonShoem

Latest Threads

Top