in reply to Re^5: getting ancestors of element
in thread getting ancestors of element

I discovered my problem is in regex
$tname =~ m/[declaration_]?name="(\w+[:]?.\w+[:]?.\w+);
where I am trying to extract the value of the name attribute which could be single word all lowercase or all uppercase, could also be Panoply::Blah or Panoply::Blah::Blah2 or have special character in name such as ~BAR In script $tname would contain something like
all_members name="~BAR" protection="public" scope="Panoply::BAR"
Also noticed from test that passing ~BAR in the argument $1 in
ret_ancestors sub {@list = join(" => ", @_)}, $nitemstr, $1;
Does not return a list because of ~ character. Any help with regex appreciated.

Replies are listed 'Best First'.
Re^7: getting ancestors of element
by jccunning (Acolyte) on Sep 08, 2012 at 22:44 UTC
    Fixed it everything appears to work now with this regex
    $tname =~ m/[declaration_]?name="(.*?)"/;
      I don't think so
      use YAPE::Regex::Explain; print YAPE::Regex::Explain->new( qr/[declaration_]?name="(.*?)"/ )->explain; __END__ The regular expression: (?-imsx:[declaration_]?name="(.*?)") 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): ---------------------------------------------------------------------- [declaration_]? any character of: 'd', 'e', 'c', 'l', 'a', 'r', 'a', 't', 'i', 'o', 'n', '_' (optional (matching the most amount possible)) ---------------------------------------------------------------------- name=" 'name="' ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- .*? any character except \n (0 or more times (matching the least amount possible)) ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- " '"' ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------

      http://perldoc.perl.org/perlintro.html#Regular-expressions/perlrequick