Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Answer: Subroutines in a regex?

by alfie (Pilgrim)
on Apr 05, 2001 at 13:39 UTC ( #70035=categorized answer: print w/replies, xml ) Need Help??

Q&A > regular expressions > Subroutines in a regex? - Answer contributed by alfie

busunsl is right, but I'd like to add another feature and DWIM[1] to your code:
s/(SUM(\d*))/&sum($2)/eg
For I think you want to have the SUM characters stripped off, don't you?

[1] Do What I Mean
--
Alfie

Replies are listed 'Best First'.
Re: Answer: Subroutines in a regex?
by busunsl (Vicar) on Apr 05, 2001 at 14:56 UTC
    Sorry to disagree, but you don't have to put parenthesis around the whole pattern, it will be substituted anyway.
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[LanX]: a friend of mine learned French with her African boyfriend ... I have to force my stop grinning when I hear a little blonde who adopted that accent
LanX .oO( *you* don't exist, I'm only messaging to *me* self)
LanX will abandon FF soon

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2017-03-27 16:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.