Text functions in general are described under G2 Text Manipulation Functions and G2 Conventions for Manipulating Text. G2 functions in general are described in Chapter 25, Functions.
Locating a Substring Using a Regular Expression
find-next-pattern (search-pattern: text, source-text: text, start-position: integer)
-> structure (start-index: integer, end-index: integer)
structure (start-index: 0, end-index: 0)
find-next-pattern ("{A-Z}{a-z}*", "according to Will Rogers", 1)
-> structure (start-index: 14, end-index: 17)
find-next-pattern ("{A-Z}{a-z}*", "according to Will Rogers", 15)
-> structure (start-index: 19, end-index: 24)
find-next-substring-matching-pattern
(search-pattern: text, source-text: text, start-position: integer)
->substring: text
find-next-pattern, except that the function returns the matching substring itself, rather than the substring's start and end positions. If no match exists, the function returns the empty string (*"). Example:
find-next-substring-matching-pattern
("{A-Z}{a-z}*", "according to Will Rogers", 1)->"Will"
find-and-replace-patternsearch-pattern
(: text,text-to-substitute: text,source-text: text,start-position: integer,end-position: integer)
->modified-text: text
find-and-replace-pattern ("abcd", "cdab", "abcdcdef", 1, 8)
-> "ababcdef"