onigleam/options
Types
Flag properties parsed from the flags string
pub type FlagProperties {
FlagProperties(
ignore_case: Bool,
dot_all: Bool,
extended: Bool,
digit_is_ascii: Bool,
posix_is_ascii: Bool,
space_is_ascii: Bool,
word_is_ascii: Bool,
text_segment_mode: option.Option(TextSegmentMode),
)
}
Constructors
-
FlagProperties( ignore_case: Bool, dot_all: Bool, extended: Bool, digit_is_ascii: Bool, posix_is_ascii: Bool, space_is_ascii: Bool, word_is_ascii: Bool, text_segment_mode: option.Option(TextSegmentMode), )Arguments
- ignore_case
-
Case-insensitive matching (i flag)
- dot_all
-
Dot matches newlines (m flag in Onig, s in JS/PCRE)
- extended
-
Extended mode - whitespace and comments (x flag)
- digit_is_ascii
-
\d matches ASCII digits only (D flag)
- posix_is_ascii
-
POSIX classes match ASCII only (P flag)
- space_is_ascii
-
\s matches ASCII space only (S flag)
- word_is_ascii
-
\w matches ASCII word chars only (W flag)
- text_segment_mode
-
Text segment mode for \X
Options for parsing Oniguruma patterns
pub type ParseOptions {
ParseOptions(
flags: option.Option(String),
capture_group: Bool,
singleline: Bool,
)
}
Constructors
-
ParseOptions( flags: option.Option(String), capture_group: Bool, singleline: Bool, )Arguments
- flags
-
Oniguruma flags string (e.g., “im” for case-insensitive and multiline)
- capture_group
-
Enable ONIG_OPTION_CAPTURE_GROUP behavior When true,
(creates capturing groups even with named groups present - singleline
-
Enable ONIG_OPTION_SINGLELINE behavior When true,
^and$match only string start/end (like \A and \z)
Target platform
pub type Target {
Erlang
JavaScript
}
Constructors
-
Erlang -
JavaScript
Text segment matching mode
pub type TextSegmentMode {
Grapheme
Word
}
Constructors
-
GraphemeGrapheme cluster mode (y{g})
-
WordWord mode (y{w})
Combined options for the conversion process
pub type ToRegexpOptions {
ToRegexpOptions(
parse: ParseOptions,
transform: TransformOptions,
)
}
Constructors
-
ToRegexpOptions(parse: ParseOptions, transform: TransformOptions)Arguments
- parse
-
Parsing options
- transform
-
Transform options
Options for transforming to gleam_regexp format
pub type TransformOptions {
TransformOptions(
allow_orphan_backrefs: Bool,
target: option.Option(Target),
)
}
Constructors
-
TransformOptions( allow_orphan_backrefs: Bool, target: option.Option(Target), )Arguments
- allow_orphan_backrefs
-
Allow orphan backreferences (references to non-existent groups) When true, creates empty groups at end to satisfy backrefs (TextMate behavior)
- target
-
Target platform for platform-specific optimizations None means generate code that works on both platforms
Values
pub fn allow_orphan_backrefs(
options: ToRegexpOptions,
) -> ToRegexpOptions
Allow orphan backreferences (for TextMate grammars)
TextMate grammars often have patterns that reference capture groups which may not exist in the current pattern. Normally this would be an error, but this option allows these references as warnings instead.
Example
import onigleam/options
let opts = options.default_options()
|> options.allow_orphan_backrefs
pub fn default_options() -> ToRegexpOptions
Default combined options
Returns options suitable for most use cases. Use the builder functions
with_flags and allow_orphan_backrefs to customize.
Example
import onigleam/options
let opts = options.default_options()
pub fn default_transform_options() -> TransformOptions
Default transform options
pub fn with_flags(
options: ToRegexpOptions,
flags: String,
) -> ToRegexpOptions
Create options with Oniguruma flags
Supported flags:
i- case-insensitive matchingm- dotAll mode (.matches newlines)x- extended mode (whitespace ignored,#comments)
Example
import onigleam/options
let opts = options.default_options()
|> options.with_flags("im") // case-insensitive + dotAll