Using explicitly numbered repetition instead of question mark, star and plus
Posted
by polygenelubricants
on Stack Overflow
See other posts from Stack Overflow
or by polygenelubricants
Published on 2010-06-13T14:39:02Z
Indexed on
2010/06/13
14:42 UTC
Read the original article
Hit count: 271
I've seen regex patterns that use explicitly numbered repetition instead of ?
, *
and +
, i.e.:
Explicit Shorthand
(something){0,1} (something)?
(something){1} (something)
(something){0,} (something)*
(something){1,} (something)+
The questions are:
- Are these two forms identical? What if you add possessive/reluctant modifiers?
- If they are identical, which one is more idiomatic? More readable? Simply "better"?
© Stack Overflow or respective owner