Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Concatenating regexs?

by japhy (Canon)
on May 04, 2001 at 17:48 UTC ( #77954=note: print w/replies, xml ) Need Help??

in reply to Concatenating regexs?

It's hard to just "group" together regexes into one regex, unless you make a "dispatch table".
s/([b-zA-Z]):/\1/g; s/[aV] /A /g; s/a: /A: /g; s/2:/2 %/g; s/9|3:/&/g; s/([aeO])I/\1j/g; tr/QRC@6{/Orx**E/; my %trans; $trans{"$_:"} = $_ for 'b' .. 'z', 'A' .. 'Z'; $trans{"$_ "} = "A " for 'a', 'V'; $trans{"a: "} = "A: "; $trans{"2:"} = "2 %"; $trans{$_} = "&" for 9, '3:'; $trans{"${_}I"} = "${_}j" for 'a', 'e', 'O'; my $regex = join '|', map quotemeta($_), keys %trans; ### WARNING -- this does not allow for nested ### translations (like (A => 'BC', B => 'D') on ### the string "A" will yield "BC", not "DC") $string =~ s/($regex)/$trans{$1}/g; $string =~ tr/QRC@6{/Orx**E/;

japhy -- Perl and Regex Hacker

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://77954]
[choroba]: and shows a bar with a note "ohne Triangel"
[choroba]: where "ohne" means "will bend" in Czech
[LanX]: one-day-the- triangle-player-of -an-orchestra-gets -very-sick xD
[choroba]: :)

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2017-03-27 12:02 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (319 votes). Check out past polls.