Skip to content

Or method enhancements #4

Open
Open
@metal3d

Description

@metal3d

Still working on implementatin, I see the whole implementation (excepting mine, but I'm wrong to implement this before speaking about with you) uses this kind of method:

or(value)
=> ...|value

I'm afraid that this one is not very usefull. It can be ok for simple test, but what about finding:

startofline, then "foo", then "bar", endofline
OR
startofline, then "bar", then "baz". endofline

My implementation does:

StartOfLine().Then("foo").Then("bar").EndOfLine().Or().StartOfLine().Then("bar").Then("baz").EndOfLine()

That returns:

(?m)(?:^(?:foo)(?:bar)$)|(?:^(?:bar)(?:baz)$)

I only record an array of "parts" to concatanate at compile time... My unittest work as expected.

That works with simple expressions, or multiple expressions...

Find("foo").Or().Find("bar")
(?m)(?:foo)|(?:bar)

StartOfLine().Then("foo").Then("bar").EndOfLine().
Or().StartOfLine().Then("bar").Then("baz").EndOfLine().
Or().StartOfLine().Find("AAA").EndOfLine().
(?m)(?:^(?:foo)(?:bar)$)|(?:^(?:bar)(?:baz)$)|(?:^(?:AAA)$)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions