sounds a bit muddy ...<br><br>just to clarify, what I found to my surprise, is that<br><br>$exp =~ s/(\s)$1+/$1/g;<br><br>replaces mixed strings of white space with the first character. leading me to conclude that the first $1 actually is the \s, not the specific character matched. However, in the second part of the s, the $1 did indeed give the white space. So the $1 in the context of searching appears to render as the regex, not the characters matched. While in the context of replacing, the $1 renders as the actual characters matched, not the regex used.<br>
<br>hope that makes it clearer.<br><br>oh - perl 5.14.2.<br><br>-rob<br><br><div class="gmail_quote">On Sat, Oct 27, 2012 at 7:37 PM, Rob Janes <span dir="ltr"><<a href="mailto:janes.rob@gmail.com" target="_blank">janes.rob@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">That's what I thought.</p>
<p dir="ltr">Until I tried it. The second use case does not work with $1.</p>
<p dir="ltr">Try it.</p><div class="HOEnZb"><div class="h5">
<div class="gmail_quote">On Oct 27, 2012 7:22 PM, "Uri Guttman" <<a href="mailto:uri@stemsystems.com" target="_blank">uri@stemsystems.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 10/27/2012 06:57 PM, Rob Janes wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
$1 doesn't work.<br>
<br>
\1 is the characters matched while $1 is the pattern matched.<br>
<br>
It only matters if u want to match pure string.<br>
</blockquote>
<br>
that is wrong. both are only references to a grab which is always a string. you can use \1 in the regex to match what you have previously matched and grabbed. $1 is used in the replacement or after the regex to get what was grabbed. neither contains a regex.<br>
<br>
uri<br>
<br>
</blockquote></div>
</div></div></blockquote></div><br>