Represents options passed to regex match methods such as Regex#match.
1 Force pattern anchoring at the start of the subject.
2 Force pattern anchoring at the end of the subject.
Unsupported with PCRE.
4 Disable JIT engine.
Unsupported with PCRE.
8 Do not check subject for valid UTF encoding.
This option is potentially dangerous and must only be used when the subject is guaranteed to be valid (e.g. String#valid_encoding?). Failing to do so can lead to undefined behaviour in the regex library and may crash the entire process.
NOTE String is supposed to be valid UTF-8, but this is not guaranteed or enforced. Especially data originating from external sources should not be trusted.
UTF validation is comparatively expensive, so skipping it can produce a significant performance improvement.
subject = "foo" if subject.valid_encoding? /foo/.match(subject, options: Regex::MatchOptions::NO_UTF_CHECK) else raise "Invalid UTF in regex subject" end
A good use case is when the same subject is matched multiple times, UTF validation only needs to happen once.
This option has no effect if the pattern was compiled with CompileOptions::MATCH_INVALID_UTF when using PCRE2 10.34+.
0 15 Returns true if this enum value contains ANCHORED
Returns true if this enum value contains ENDANCHORED
Returns true if this enum value contains NO_JIT
Returns true if this enum value contains NO_UTF_CHECK
Enum
Enum
Enum
Enum
Comparable(Enum)
Value
Object
Object
Object
Returns true if this enum value contains ENDANCHORED
Returns true if this enum value contains NO_UTF_CHECK
© 2012–2026 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/1.19.0/Regex/MatchOptions.html