Jeff is on the right track, but you have to use the second syntax of 'catch' with the extra parameter symbol to check for error exceptions:
Code: Select all
(catch (regex ".+?+" "a string") 'result)
If the there was an error the whole expression will return 'nil' and you have the error message in 'result'.
Else if the whole expression returns 'true', there was no error and you can inspect 'result' for the result of the the 'regex' expression, which still may be 'nil' if there was no match. Here is the whole picture:
Code: Select all
(catch (regex ".+?+" "a string") 'result) => nil
result => regular expression in function regex : "offset 3 nothing to repeat:"
(catch (regex "r" "a string") 'result) => true
result => ("r" 4 1)
(catch (regex "x" "a string") 'result) => true
result => nil
Lutz