in reply to Re^2: regex match unicode characters in ascii string
in thread regex match unicode characters in ascii string

Ok . try this

#!perl use strict; use HTML::Entities; use Data::Dump 'pp'; my $string = "Group: Group Name▼▼Role: Role Name"; $string = decode_entities($string); my @f=(); while ( $string =~ /(Group|Role)\:\s+([\x00-\x7f]*)/g ){ push @f,$2; }; pp \@f;
poj

Replies are listed 'Best First'.
Re^4: regex match unicode characters in ascii string
by 3dbc (Monk) on Jan 27, 2017 at 20:40 UTC
    Thanks works well, but is only catching the last occurrence... meaning it only matches the role name, not the group name too. Need it to match both and ignore anything else so that I can update the DBI hashref with this info.
    - 3dbc

      Are you running the code I posted ?. If not can you please post the string that is not working so I can replicate the error.

      poj
        Yes, I'm using your code. like i said it works, but $2 only has the role name, not the group name. ideally I'd like $2 to have the group name and $3 to have the role name.

        I updated the original post. The string gets messed up when you post it with < code > tags.

        my $string ="Group: Group Name▼▼Role: Role Name"

        Thanks!
        - 3dbc