perlquestion
SavannahLion
<div class="pmsig"><div class="pmsig-282117">
I'm hoping someone can clarify some behavior for me.<br>
I have the following two code blocks I'm fiddling with. First I tried the following block.<br>
<code>
my $phrase = "This is a test, \"using quotes of 'two different' types.\"";
$phrase =~ s/[\S*\W*]//g;
print $phrase;
</code><br>
For some reason, the regex destroys the entire line. Therefor, print just prints a blank line. So after some fiddling I came up with the following block.<br>
<code>
my $phrase = "This is a test, \"using quotes of 'two different' types.\"";
$phrase =~ s/[^\s*\w*]//g;
print $phrase;
</code><br>
Which does exactly what I was aiming for in the first place. It produces the following line: <i>This is a test using quotes of two different types</i> All quotes, periods, and everything else has been stripped.<p>
In my llama book it states that [^\s] is the same as \S and [^\w] is the same as \W. Now, from what I understand so far, the first block of code should have worked, but it didn't.<br>
Why is that?
<p>
Is it fair to stick a link to my site here?<p>
Thanks for you patience.
</div></div>