Next: RegexResults, Previous: RecursionLock, Up: Base classes [Index]
A Regex is a read-only string for which the regular expression matcher can cache a compiled representation, thus speeding up matching. Regex objects are constructed automatically by methods that expect to match many times the same regular expression, but can also be constructed explicitly sending #asRegex to a String or Symbol.
Creation of Regex objects inside a loop is of course slower than creating them outside the loop, but special care is taken so that the same Regex object is used whenever possible (when converting Strings to Regex, the cache is sought for an equivalent, already constructed Regex).
• Regex class-instance creation: | (class) | |
• Regex-basic: | (instance) | |
• Regex-conversion: | (instance) | |
• Regex-printing: | (instance) |