YAPE::Regex::Explain is a handy tool to explain it for you.
use YAPE::Regex::Explain; $search = "\x8C\x95"; $encoding = q{ # Shift-JIS encoding [\x00-\x7F] # ASCII/JIS-Roman | [\x81-\x9F\xE0-\xFC][\x40-\x7E\x80-\xFC] # JIS X 0208:1997 | [\xA0-\xDF] # Half-width katakana }; $regex = qr/^ (?:$encoding)*? $search/osx; print YAPE::Regex::Explain->new($regex)->explain;
Outputs:
The regular expression: (?sx-im:^ (?: # Shift-JIS encoding [\x00-\x7F] # ASCII/JIS-Roman | [\x81-\x9F\xE0-\xFC][\x40-\x7E\x80-\xFC] # JIS X 0208:1997 | [\xA0-\xDF] # Half-width katakana )*? от) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?sx-im: group, but do not capture (with . matching \n) (disregarding whitespace and comments) (case-sensitive) (with ^ and $ matching normally): ---------------------------------------------------------------------- ^ the beginning of the string ---------------------------------------------------------------------- (?: group, but do not capture (0 or more times (matching the least amount possible)): ---------------------------------------------------------------------- [\x00-\x7F] any character of: '\x00' to '\x7F' ---------------------------------------------------------------------- | OR ---------------------------------------------------------------------- [\x81-\x9F\xE0- any character of: '\x81' to '\x9F', \xFC] '\xE0' to '\xFC' ---------------------------------------------------------------------- [\x40-\x7E\x80- any character of: '\x40' to '\x7E', \xFC] '\x80' to '\xFC' ---------------------------------------------------------------------- | OR ---------------------------------------------------------------------- [\xA0-\xDF] any character of: '\xA0' to '\xDF' ---------------------------------------------------------------------- )*? end of grouping ---------------------------------------------------------------------- от 'от' ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------

--

flounder


In reply to Re: regex question by flounder99
in thread regex question by Deda

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.