I was trying to generate a regex to be used in Java using this link.
I can have the following kind of strings.
1. customer calls <function_name> using <verb> on <uri> with <object>
2. customer calls <function_name> using 'POST' on <uri> with <object>
3. customer calls 'create' using 'POST' on <uri> with <object>
4. customer calls 'create' using 'POST' on <uri>
As you can see, the last portion after with is optional in my case.
I implemented the following regular expression.
.+call[s]?.+(\'\w+\'|<\w+>).+using.+(\'\w+\'|<\w+>).+on.+(\'\w+\'|<\w+>).*(with.+(\'\w+\'|<\w+>))?
But when I give string 3, I am getting the output as 'create','POST',<object>, null, null instead of 'create','POST',<uri>, <object>.
When I give string 4, the output is 'create','POST',<uri>, null, null instead of 'create','POST',<uri>.
The regex without (with.+(\'\w+\'|<\w+>))? works properly for string 4.
How can I change this last part where I need to make the section from with optional?