what does /^[^ ]/ mean in perl?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Monica Pnade

    #1

    what does /^[^ ]/ mean in perl?

    what does /^[^ ]/ mean in perl?
  • toolic
    Recognized Expert New Member
    • Sep 2009
    • 70

    #2
    It is a regular expression which matches any non-space character at the beginning of a string.

    perlre

    YAPE::Regex::Ex plain

    Code:
    use strict;
    use warnings;
    
    use YAPE::Regex::Explain;
    print YAPE::Regex::Explain->new(qr/^[^ ]/)->explain();
    
    __END__
    
    The regular expression:
    
    (?-imsx:^[^ ])
    
    matches as follows:
    
    NODE                     EXPLANATION
    ----------------------------------------------------------------------
    (?-imsx:                 group, but do not capture (case-sensitive)
                             (with ^ and $ matching normally) (with . not
                             matching \n) (matching whitespace and #
                             normally):
    ----------------------------------------------------------------------
      ^                        the beginning of the string
    ----------------------------------------------------------------------
      [^ ]                     any character except: ' '
    ----------------------------------------------------------------------
    )                        end of grouping
    ----------------------------------------------------------------------

    Comment

    Working...