Finding trouble in getting the following regex work to put the string between quotes:
"\"mytext\"".replaceAll("^\"?|\"?$", "\"")
The above code gives - "mytext""
as the output, but what I require is "mytext"
.
For troubleshooting, I replaced the replaceWith character to * and the output is - *mytext**
Why is \"?$
considered as two separate matches?