I have a scenario where i have to remove special characters from a string.
Input String : name=/"xyz =bcd .olm --=myname/"
Output String Must be Like: name=/"xyz bcd olm myname/"
I tried something like below and still not able to come up with the exact regex. Can anyone help me to figure out what i have done wrong?
String inputString = "name=\"xyz =bcd .olm --=myname\"";
String regex = "(?<=name=\")[^<]*(?<!/)(\\w+)(?=[^>]*>)";
String outputString = inputString.replaceAll(regex, "$1");
System.out.println(outputString);
For the replacement. You need to first get the content value of name field. Then you can remove special characters from the string.
Example code block:
Result prints as
name="xyz bcd olm myname"