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

Re: "Inverse" Pattern Matching

by LanX (Canon)
on Jul 04, 2013 at 20:54 UTC ( #1042522=note: print w/ replies, xml ) Need Help??


in reply to "Inverse" Pattern Matching

we had a similar question not long ago: Using special characters in left part of a regex match?

In short: It's not easy!!!

I'm not sure how efficient it is but I might try to code all possibilities into a long or-clause

/(12345x|1234x6|123x56|123x6| ...)/

please note that from 5.10 on such expressions are efficiently trie-optimized.

Another approach could be to match all "x" and surrounding n bytes to be further investigated...

edit

something like /(1 [2-5]{0,4} x [2-5]{0,4} 6)/gx in a while loop to narrow the set of possible matches.

Cheers Rolf

( addicted to the Perl Programming Language)


Comment on Re: "Inverse" Pattern Matching
Select or Download Code
Replies are listed 'Best First'.
Re^2: "Inverse" Pattern Matching
by hdb (Prior) on Jul 05, 2013 at 12:22 UTC

    Thanks a lot. The long or-clause probably grows exponentially with the length of the pattern but if I combine it with your other proposal it might work.



Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2015-07-28 03:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (252 votes), past polls