Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Regex backreference without capture

by rsFalse (Hermit)
on Mar 01, 2019 at 15:52 UTC ( #1230718=note: print w/replies, xml ) Need Help??

in reply to Regex backreference without capture

Hello, QM,

Haven't heard about such capture groups for only backreferences.
Interestingly, if any simple overcome exist? This overcome below looks ugly:
#!/usr/bin/perl -wl print map "[$_]", "bogus firstblahj?keblahthird bogus" =~ / (?| (*F) | first ( (blah) .*? \2 ) third (?{ $L = $1 }) (*THEN) (*F) # 1 2 2 1 | (??{ defined $L ? "" : "(*F)" }) (first) (??{ print "mid-match:[$L]" ; quotemeta $L }) (third +) # 1 1 2 +2 ) /x;
mid-match:[blahj?keblah] [first][third]
Idea here is to use conditional '(?|...)' with 2 groups, save mid-match (if full match is successful), fail first branch anyway, then match same thing on alternative branch rewriting $1 and $2, and using previously defined mid-match to avoid captures.

Replies are listed 'Best First'.
Re^2: Regex backreference without capture
by QM (Parson) on Mar 05, 2019 at 10:31 UTC
    Thanks. But I think that's too complex for any normal usage. (I'd hate to maintain that, even if I was the only coder.)

    But seriously, thanks. Maybe this will spur more ideas?

    Quantum Mechanics: The dreams stuff is made of

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2021-10-18 14:53 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (74 votes). Check out past polls.