On several occasions, I have felt that built-in regex support in GNU APL would be very helpful.
Implementing it should be rather simple, but I'd like to discuss how such an API should look in order for it to be as useful as possible. I was thinking of the following form: regex ⎕Regex string The way I envision this to work, is to have the function return ⍬ if there is no match, or a string containing the match, if there is one: * 'f..' ⎕Regex 'xzooy'* ┏⊖┓ ┃0┃ ┗━┛ * 'f..' ⎕Regex 'xfooy'* 'foo' If the regex has subexpressions, those matches should be returned as individual strings: * '([0-9]+)-([0-9]+)-([0-9]+) '⎕Regex '2017-01-02'* ┏→━━━━━━━━━━━━━━━┓ ┃"2017" "01" "02"┃ ┗∊━━━━━━━━━━━━━━━┛ This would be a very useful API, and reasonably easy to implement by simply calling into the standard regcomp() call: http://pubs.opengroup.org/onlinepubs/009695399/functions/regcomp.html What do you think? Is this a reasonable way to implement it? Any suggestions about alternative API's? Regards, Elias