XReguex is an AppleScript library to process text with regular rexpressions. It's a wrapper of NSRegularExpression.
In simple cases, class methods of search, search_all and replace_matches.
search methods returns a MatchResult object for first matched text.When matched texts with the regular expressions can not be found, missig value is returned.
You can obtaine matched texts and range by using capture and range methods of MatchResult object.
When the regular expression is used repeatedly, compile the regular rexpression with make_with and store obtained XRegex instance. And use instance methods of first_match, matches_in, replace.
For syntax of regular expression, see the pages of NSRegularExpression and ICU.
Returns the first match of the regular expression in the text.
Returns a list containing all the matches of the regular expression in the text.
Returns the number of matches of the regular expression in the text.
Returns a new text containing matching regular expressions replaced with the template text.
Compile a regular expression and return a new XRegex instance.
Returns the first match of the regular expression in the text.
Returns a list containing all the matches of the regular expression in the text.
Returns the number of matches of the regular expression in the text.
Returns a new text containing matching regular expressions replaced with the template text.
Returns a list by splitting a given text with delimiters which are matched texts with the pattern.
MatchResult is a wapper of NSTextCheckingResult which expresses pattern maching results. Each MatchResult object contains infomation about matched texts with the pattern and caputred groups. These infomation can be obtained by using capture and range methods.
MatchResult objects are returned by search, search_all, first_match and matches_in.
The location value of range is zero based i.e. follows the manner of NSString not the manner of AppleScript's text.To obtain substring of the range calculated from returned value of range in the searched text, use substring or substring_from, because NSString's character counts and indexes may not be able to exchanged for AppleScript's text.
Returns a number of matched ranges.
Returns a text matched with the regular expression and texts of capture groups.
Returns a whole text matched with the regular expression.
Returns the range mateched with the regular expression and groups.
Returns the substring specified with location and langth in searched text
Returns the substring from specified location to the end in searched text.