Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: HELP! I am in regex-hell

by kcott (Archbishop)
on Jul 15, 2020 at 07:42 UTC ( [id://11119348]=note: print w/replies, xml ) Need Help??


in reply to HELP! I am in regex-hell

You could simply exclude the opening parenthesis from the page capture and the closing parenthesis from the section capture like so:

/^([^(]+)\(([^)]*)/

Here's a test with your four examples:

$ perl -E ' my @manpages = qw{ ftpd(8) dhcp-config(5) Cache::Cache(3) Tk::widget::demo(3) }; for my $line (@manpages) { my ($page , $section) = $line =~ /^([^(]+)\(([^)]*)/; say "page[$page] section[$section]"; } ' page[ftpd] section[8] page[dhcp-config] section[5] page[Cache::Cache] section[3] page[Tk::widget::demo] section[3]

— Ken

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2024-04-25 01:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found