in reply to Re^6: regex match unicode characters in ascii string
in thread regex match unicode characters in ascii string
I thought you said in an earlier reply you wanted an array. If you want a hash ref then try this, the while loop matches both values
poj#!perl use strict; use HTML::Entities; use Data::Dump 'pp'; my $string = "Group: Group Name▼▼Role: Role Name"; $string = decode_entities($string); my $href={}; while ( $string =~ /(Group|Role)\:\s+([\x00-\x7f]*)/g ){ $href->{$1} = $2; }; pp $href; print "Role = $href->{'Role'}\n"; print "Group= $href->{'Group'}\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: regex match unicode characters in ascii string
by 3dbc (Monk) on Jan 27, 2017 at 21:35 UTC | |
by poj (Abbot) on Jan 27, 2017 at 22:17 UTC | |
by 3dbc (Monk) on Jan 27, 2017 at 22:40 UTC |