Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Regex Parsing Chars in a Line

by rsFalse (Chaplain)
on Nov 24, 2019 at 21:23 UTC ( [id://11109160]=note: print w/replies, xml ) Need Help??


in reply to Regex Parsing Chars in a Line

Hi.
So what is your question? What do you want to achieve and what is your data? Can you elaborate more? You say about parentheses in one place, then about hyphens in another.

I'll try to rewrite last of your regex in more readable form with '/x' modifier:
$name =~ s/ (\() # $1 (.+) # $2 (?!\)) /$1$2\)/gx;

Replies are listed 'Best First'.
Re^2: Regex Parsing Chars in a Line
by kel (Sexton) on Nov 26, 2019 at 04:58 UTC
    The parenthesis repacement with the lookahead works. I thought that the solution to the hyphen issue should work with lookahead/behinds, but it didnt. I apoolgize for the confusion, but that example was only to show that the basic mechanism worked on Perl v26 in Win. Oddly, some operators seem to be recalcitrant on Win, as opposed to Linux. Even with stripping permissions/ownership of target files. I am looking for a clean method for parsing hyphens, and my current method often requires a second run.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-03-28 09:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found