Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: HELP! I am in regex-hell

by LanX (Saint)
on Jul 14, 2020 at 23:53 UTC ( [id://11119329]=note: print w/replies, xml ) Need Help??


in reply to HELP! I am in regex-hell

use character classes or or conditions | to include the missing characters

But your regex seems wrong anyway, since there is a space in between

DB<1> $line = 'Cache::Cache(3)' DB<2> x ($page , $section) = ( $line =~ /^((?:\w|:|-)+)(\(.*?\))?/) 0 'Cache::Cache' 1 '(3)' DB<3> $line = 'dhcp-config(5)' DB<4> x ($page , $section) = ( $line =~ /^([\w:-]+)(\(.*?\))?/) 0 'dhcp-config' 1 '(5)' DB<5>

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: HELP! I am in regex-hell
by Anonymous Monk on Jul 15, 2020 at 20:35 UTC

    Eh Rolf -- thanks! I messed with the following line:

    ($page , $section) = ( $line =~ /^((?:\w|:|-)+)(\(.*?\))?/)

    This did what I wanted. I needed to keep "\(.*?\)" because that block is used elsewhere in the code. I found it amazing that the first chunk was so simple. I was over-complicating the matter...

Re^2: HELP! I am in regex-hell
by Anonymous Monk on Jul 15, 2020 at 12:50 UTC

    DOH! ... The space was not intended. I cant keep all those () straight while reading my code.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-26 05:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found