what are default options? `Regex` constructors ai...
# stdlib
m
what are default options?
Regex
constructors ain't even documented..
I guess there are no default options?
Regex
implementation on JVM target uses
Pattern.compile(String)
for compiling patterns without any options.
c
In that case of creating a regex from a string, correct. The Regex class offers a few constructors, such as
Copy code
/** Creates a regular expression from the specified [pattern] string and the specified set of [options].  */
    public actual constructor(pattern: String, options: Set<RegexOption>) : this(Pattern.compile(pattern, ensureUnicodeCase(options.toInt())))
allowing creation with options, passed through to Pattern.compile.
m
Yeah, that's what I mean
I think that
with the default options
part should be removed. Or does it really use some default options on other targets like JS?
c
it is correctly stated but omits stating what the default options are, assuming that folks know that it’s Pattern.compile under the hood (and what the default options there are).
m
@Chris Lee that's the point,
Pattern.compile(Striing)
does not introduce default options
c
it does, implicitly - the default options are none of the available ones.
m
the default options are none
so?
n
Regex has some default behavior (e.g. matches are case-sensitive by default). This "with the default options" indicates that the resulting Regex object uses these default options. You can changes them either within the pattern (e.g.
(?i)
), or by using the constructor.