Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Here's some data to illustrate what is happening. I think davido's explanation really hits the nail on the head and Anonymous Monk's suggestion YAPE::Regex::Explain will help you isolate what is happening with your experimentation. BTW, including an asterisk in some of the character classes is redundant, other times, you might see all your asterisks disappear from your input---not what you intended, I think.

ladoix% cat 312141.pl #!usr/bin/perl use strict; use warnings; my $phrase1 = "This is a test, \"using quotes of 'two different' types +.\""; $phrase1 =~ s/[\S\W]*//g; print "P1: [$phrase1]\n"; my $phrase2 = "This is a test, \"using quotes of 'two different' types +.\""; $phrase2 =~ s/[\S\w]*//g; print "P2: [$phrase2]\n"; my $phrase3 = "This is a test, \"using quotes of 'two different' types +.\""; $phrase3 =~ s/[\s\W]*//g; print "P3: [$phrase3]\n"; my $phrase4 = "This is a test, \"using quotes of 'two different' types +.\""; $phrase4 =~ s/[\s\w]*//g; print "P4: [$phrase4]\n"; my $phrase5 = "This is a test, \"using quotes of 'two different' types +.\""; $phrase5 =~ s/[^\s\w]*//g; print "P5: [$phrase5]\n"; my $phrase6 = "This is a test, \"using quotes of 'two different' types +.\""; $phrase6 =~ s/[^\S\w]*//g; print "P6: [$phrase6]\n"; my $phrase7 = "This is a test, \"using quotes of 'two different' types +.\""; $phrase7 =~ s/[^\s\W]*//g; print "P7: [$phrase7]\n"; my $phrase8 = "This is a test, \"using quotes of 'two different' types +.\""; $phrase8 =~ s/[^\S\W]*//g; print "P8: [$phrase8]\n"; ladoix% perl 312141.pl P1: [] P2: [ ] P3: [Thisisatestusingquotesoftwodifferenttypes] P4: [,"''."] P5: [This is a test using quotes of two different types] P6: [Thisisatest,"usingquotesof'twodifferent'types."] P7: [ , " ' ' ."] P8: [This is a test, "using quotes of 'two different' types."]

--
Allolex


In reply to Re: ^\s not equal \S? by allolex
in thread ^\s not equal \S? by SavannahLion

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (6)
    As of 2020-02-28 19:31 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      What numbers are you going to focus on primarily in 2020?










      Results (127 votes). Check out past polls.

      Notices?