L
L
Leon Brock2018-04-25 19:41:09
Regular Expressions
Leon Brock, 2018-04-25 19:41:09

Checking a string against a pattern?

I want to implement a validation function, to which a string is passed and then this string is checked against the templates from the database until a suitable one is found or false if nothing is found at all.
A string pattern is something like regex but more simplified. For example:
"[Hello, Hello, Good afternoon, Hello]" - these are all words that can be in the input, examples:
- Input string : "Hello" - true -
Input string: "Hello" - true
- Input string: " Bye" - false
* - any number of characters, template: "[Hello, Hello, Good afternoon, Hello], * [business, life, health, family]?"
- Input string: "Hey, how are you?" - false
- Input string: "Hi, how are you?"
- Input string: "Good afternoon, how are you?" - true
[:param] - set parameter, pattern "[Hello, Hello], I'm [:name]"
- Input string: "Hi, I'm Human" - function returns json {name: "Person"}
~ word with arbitrary ending , pattern: [Privet~]
- Input string: "Pruvet" - false
- Input string: "Hello" - true
- Input string: "Privet" - true - Input string: "Privet" - true
-
Input string: "Privandre" - true
Something like this is implemented in iii.ru for training bots, but I read somewhere that they work through AI.
Is it really impossible to do without AI?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2018-04-25
@LeonBrock

full text search

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question