Mikhail

    Mikhail

    4 months ago
    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

    Chris Lee

    4 months ago
    In that case of creating a regex from a string, correct. The Regex class offers a few constructors, such as
    /** 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.
    Mikhail

    Mikhail

    4 months ago
    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

    Chris Lee

    4 months ago
    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).
    Mikhail

    Mikhail

    4 months ago
    @Chris Lee that's the point,
    Pattern.compile(Striing)
    does not introduce default options
    c

    Chris Lee

    4 months ago
    it does, implicitly - the default options are none of the available ones.
    Mikhail

    Mikhail

    4 months ago
    the default options are none
    so?
    n

    nkiesel

    4 months ago
    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.