Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: regex match unicode characters in ascii string

by 3dbc (Monk)
on Jan 27, 2017 at 20:17 UTC ( [id://1180493]=note: print w/replies, xml ) Need Help??


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

Thanks for posting, but I used that regex and it returned:

Group:= Group Name▼▼Role: Role Name

Trying to get all the group, role names into a group / role keys within a DBI $hashref which I already have, but want to add these key value pairs that have values without the Group: / Role: identifier and minus any of the extended ascii characters. Kind of cleaning up the values and organizing the data so I can work on it elsewhere.
- 3dbc
  • Comment on Re^2: regex match unicode characters in ascii string

Replies are listed 'Best First'.
Re^3: regex match unicode characters in ascii string
by poj (Abbot) on Jan 27, 2017 at 20:22 UTC

    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
      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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1180493]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-19 10:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found