and the [\.] is redundant, it's the same like [.] and won't match everything

Yes, I am aware of that. However the OP's question was to explain why the regex he provided, in all its baroque splendour, did not match both the input lines. I think it would be distracting to go changing his regex and then explain how the modified form works rather than answer the question as posed. There are plenty of things I would change about the given regex to achieve the same end were I to write it of which this is merely one. Although the first thing would be to lose the /x which is causing far more confusion than it removes in this case IMHO.

or a literal pipe symbol |

That's a good observation and I'll amend my post to mention it. Thanks.


🦛


In reply to Re^3: Regex, match one or other character class by hippo
in thread Regex, match one or other character class 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.