Hi monks,

I want to use the back reference in s///g, but seems I failed with code below:

$in =~ s/\s+/\n/g; $in =~ s/[a-zA-Z]\n[a-zA-Z]/$1\ $2/g;
First I cut the character (non-English) by space, then I join them back if I cut them wrongly (e.g. space between 2 English alphabet). I found the regular expression in line 2 failed - the space is located correctly, but the character before and after were missing and replaced by null (so I see character disappeared) - then I know the back reference here is not working. Did I failed to call the back reference just because of my stupid syntax error?

In reply to Back reference in s///g ? 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.