I am using Cucumber java. In a step definition, I would like to use a question mark as a string and not to be considered as a regex, which means I need to escape it. I have seen this topic about escaping and tried to apply :
@When("^I make PUT /service/(.*)/url\\?pathParam=(.*)$")
In the feature file, the step would appear as :
When I make PUT /service/<string>/url\?pathParam=<string>
(please note the backslash in front of the question mark)
I would like to get :
When I make PUT /service/<string>/url?pathParam=<string>
How should I write my step so the question mark is correctly escaped, with no additional character added?
Edit : Using a single backslash in front of the question mark results with an illegal escape character in string literal exception. The curious thing is that escaping a quote with a single backslash anywhere in the step doesn't display this exception.