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

Re^2: Regex: matching character which happens exactly once

by AnomalousMonk (Archbishop)
on Oct 24, 2017 at 03:05 UTC ( [id://1201938]=note: print w/replies, xml ) Need Help??


in reply to Re: Regex: matching character which happens exactly once
in thread Regex: matching character which happens exactly once

I understand that the  [^\1] regex expression presented here is intended as pseudocode, but in addition to the radical changes to backrferencing it implies, there's another problem: the syntax of character classes would have to change radically to support it. Something like  \1 in a character class is compiled as an octal character representation:

c:\@Work\Perl\monks>perl -wMstrict -le "my $rx = qr{ [\1] }xms; print $rx; print 'match' if qq{\cA} =~ $rx; " (?msx-i: [\1] ) match


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^3: Regex: matching character which happens exactly once
by QM (Parson) on Oct 24, 2017 at 09:16 UTC
    Yes. Like LanX, you're getting bogged down in implementation.

    What do you want it to do with that syntax? How would you redefine Perl regexes to do this?

    I think another symbol for backref would help. (I don't know what we'd use, but that's a different problem.) Then use the same thing for forward references. And for fun, we'll call those ferkcabs.

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

      How would you redefine Perl regexes to do this?

      But the  (?:[^\1]*) construct was envisioned to get around the lack of variable-width positive/negative lookbehind; I think I'd just implement that. (Of course, I suspect the reason it hasn't been implemented yet is because it's a royal pain to do so. Perhaps best to be careful what you wish for lest you find yourself with a new and very difficult assignment. As for implementing ferkcabs, I think I'd switch to another profession first. :)


      Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-24 09:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found