Answer the question
In order to leave comments, you need to log in
What is the correct regex for pattern?
Friends, I ask for your help. I am writing a program that generates a to-do list through the console using commands.
I need to teach the program to respond differently to two input patterns:
First: "ADD + Text" (where "ADD" is the name of the command, "Text" is the text). For example: ADD Case 4
Second: "ADD + # + Text" (where "ADD" is the name of the team, "#" is the sequence number to be assigned to the case, "Text" is the text). For example: ADD 4 Thing 4
Separating these patterns I plan to implement this with Pattern - Matcher. But it is not possible to correctly set the condition for Patterna.
Now I use the following regular expressions:
For the first one: Pattern patternAdd = Pattern.compile("
For the second one: Pattern patternAddX = Pattern.compile("ADD + \\s[0-9] + [a-zA-Z0-9]");
Including tried their various variations, but to no avail ... Can you tell me how to write regex correctly? Thanks in advance!
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question