|Just another Perl shrine|
Re: Multidimensional regular expressionsby QM (Parson)
|on Sep 20, 2005 at 20:56 UTC||Need Help??|
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
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:
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 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?)