No, [ease] is the same as [aes] and means one character which may be one of 'a', 'e', or 's'. What you want is the string ease modified by the "match either one or zero times" qualifier '?'. Since '?' has high precedence, saying ease? means the string "eas" optionally followed by 'e'. To make the '?' apply to the whole string "ease", you enclose it in parentheses (ease)?.

Since parentheses have two functions (to affect precedence and to cause capture of a submatch (e.g. into $1)) and you often want to do the former but not the latter, there is a special form of parentheses that don't capture: (?: before and ) after. This odd way of extending regex syntax was chosen since (? regex was otherwise meaningless and illegal.

Does that help?

You can install modules YAPE::Regex and YAPE::Regex::Explain and say (for example) print YAPE::Regex::Explain->new("(ease)?")->explain() to get a verbose blow-by-blow description of what a particular regex does.


In reply to Re: Re: Re: combining RegEx by ysth
in thread combining RegEx by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.