skyem123 / stringmatcher1 Goto Github PK
View Code? Open in Web Editor NEWA matching thing written in Kotlin, because RegEx is too painful on it's own. (and I wanted to try Kotlin). Now abandoned.
License: BSD 2-Clause "Simplified" License
A matching thing written in Kotlin, because RegEx is too painful on it's own. (and I wanted to try Kotlin). Now abandoned.
License: BSD 2-Clause "Simplified" License
Can we get a switch matcher? It's a set of key-value pairs (aka a HashMap (but not necessarily)) that is much faster than alternations (O(1) vs O(n)).
First you need a pattern. This pattern will be used to lookup a pattern in the map. After matching the pattern, and looking up the result in the map, there are 2 possible outcomes:
setCase(null, pattern)
. This has 2 possible outcomes:
Constructing and using switch matchers could be done as in switch(pattern).setCase(string, pattern).setCase(string, pattern).setCase(null, pattern)
.
Removing cases could be done with setCase(string, null)
.
Possible ideas:
EverythingMatcher
JetBrains/kotlin@15d6949 removes the need for my work-around code, so I should remove it when it's part of the main release.
This will be useful for testing and also be a good idea overall.
This is very important for a library, and it will also be good to have tutorials in this repo.
_Note that this issue will not be closed, as it is an important reminder to new code written_
This is a separate issue, because it is not essential.
Issue #15 seems like an interesting way to combine multiple matchers, but other ways of linking matchers together will also be useful.
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
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.