Arc Forumnew | comments | leaders | submitlogin
Regular expressions
5 points by mdemare 6140 days ago | 3 comments
Is there a way to use mzscheme's regular expression library from Arc?


7 points by chaos 6140 days ago | link

patch for ac.scm:

    1089a1090,1094
    > (xdef 'regexp regexp)
    > (xdef 'r-match regexp-match)
    > (xdef 'r-match-pos regexp-match-positions)
    > (xdef 'r-replace regexp-replace)
    > 

    arc> (= r (regexp "(-[0-9]*)+"))
    #rx"(-[0-9]*)+"
    arc> (r-match r "a-12--345b")     
    ("-12--345" "-345")
Just add what you need.

-----

2 points by sjs 6140 days ago | link

There are some funcs that may tide you over in the meantime, or at least give you a starting point to write replacements for regexes you need.

* whitec (test for a whitespace char)

* nonwhite (inverse of above)

* alphadig (test for alphanumeric chars)

* punc (true for any of [.,;:!?])

With the functions all and some, and a little subseq-fu you should be able to do what you want.

edit: Also look around the forum here for a patch to subseq to support negative indices for slicing off the end.

-----

2 points by elibarzilay 6140 days ago | link

No, but it will be easy to add it.

-----