How to escape "?" in Cucumber Java?
<p>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 <a href="https://stackoverflow.com/questions/23615714/how-to-escape-special-characters-in-cucumber-step-definitions">topic</a> about escaping and tried to apply :</p>

<pre><code>@When("^I make PUT /service/(.*)/url\\?pathParam=(.*)$")
</code></pre>

<p>In the feature file, the step would appear as :</p>

<pre><code>When I make PUT /service/&lt;string&gt;/url\?pathParam=&lt;string&gt;
</code></pre>

<p>(please note the backslash in front of the question mark)</p>

<p>I would like to get :</p>

<pre><code>When I make PUT /service/&lt;string&gt;/url?pathParam=&lt;string&gt;
</code></pre>

<p>How should I write my step so the question mark is correctly escaped, with no additional character added?</p>

<p>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.</p>