Skip to content
This repository was archived by the owner on Feb 23, 2018. It is now read-only.
This repository was archived by the owner on Feb 23, 2018. It is now read-only.

Multiple matchers #16

@skyem123

Description

@skyem123

Issue #15 seems like an interesting way to combine multiple matchers, but other ways of linking matchers together will also be useful.

Combining matchers with methods on the Matcher class

(Maybe the methods should use varargs to reduce the number of ( and ) needed.)

.and(Matcher)

This will do an and operation between the two matchers.
For a very simple example, matchAll().and(match("test")).useOn("this is a test") should only have one match result, which would be 10 4 test. This would also work reversed, for example match("test").and(matchAll()).useOn("this is a test") would have exactly the same result.

A more complex example of the .and(Matcher) system would be startsWith(match("this")).and(endsWith(match("hello"))).useOn("this is a test, hello world!") will have a single match result of 10 21 test, hello.

.or(Matcher)

This will do an or operation between the two matchers. For example, startsWith(match("this")).or(endsWith(match("hello"))).useOn("this is a test, hello world!") will have a single match result of 0 28 this is a test, hello world!
For a more complex example, match("test").or(match("hello")).useOn("this is a test, hello world!") will have two match results, 10 14 test and 16 21 hello.

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions