E
E
EVGENY T.2019-03-20 15:02:12
Java
EVGENY T., 2019-03-20 15:02:12

How to make life easier with regular expressions?

First, this is the story. I work a lot in one language where there are many simple and powerful functions for working with strings. And I often miss these features when I write in Java.
One of them is the CAN-DO(String mask, String str) function - checks if the string matches the mask. For example CAN-DO("Ivanov*", "Ivanov I.I."), CAN-DO("+7(911).......", "+7(911)7135613"). Those. the main masking characters are an asterisk (any number of characters) and a dot (one character). There's still possible denial in through! set, but it's okay you can get by with NOT CAN-DO ().
Well, that's the question. I want the same function in java, I would have attached it and didn’t know grief.
PS I know about regular expressions and matches, but I don't need 90% of their functionality. I want CAN-DO(). Can you help?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2019-03-20
@Stalker_RED

Write a wrapper that converts your masks to regular expressions and checks the regular expression.
An asterisk in .*, other characters are unchanged, and brackets with special characters are escaped.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question