Quantcast
Channel: How do we remove special characters from a string from a particular position in java? - Stack Overflow
Viewing all articles
Browse latest Browse all 3

How do we remove special characters from a string from a particular position in java?

$
0
0

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);

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>