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

Re: Multidimensional regular expressions

by QM (Parson)
on Sep 20, 2005 at 20:56 UTC ( #493600=note: print w/replies, xml ) Need Help??


in reply to Multidimensional regular expressions

Were you thinking of something along the lines of Befunge, but for regexen?

Merging a Befunge-like syntax with Perl regex syntax would be amazing. Maybe some interesting alternations such as

\d{?[^>]}
to look north and east from the "current" position for a digit.

Using NFA ideas, split the "current" position, and check more than one path. For example, look for palindromes in 1D strings:

m/( # capture whole match (.)? # 0 or 1 middle char ( # capture matched pairs . # 1 char {?\2[<]} # ...left of \2 {?[eq]} # string equal {?\2[>]} # ...right of \2 )* # zero or more times ) # close capture /x;
except that it needs some way to refer to the growing match at each point.

Solving those path problems, like "you can only move to postions which are red on odd moves, and blue or green on even moves", would be easier.

This would need to capture not only the characters matching the regex, but the path as well, since it can no longer be assumed that the chars are in a straight line. Also, can characters already matched be matched again?

This fundamentally depends on what it means to have a multideminsional string. Is a 2D string an array of strings taken in order from $x[0] to $x[$#x]? Is a 3D string an AoA of strings? Or is a 2D string just a normal string with more than one newline? (Then what would a 3D string look like?)

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2021-03-01 05:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?