Removing a space from a string

Asked 2 years ago, Updated 2 years ago, 156 views

mysz="name=johnage=13year=2001";I looked for a string of this type because I wanted to erase the space, and there is a method called trim() that removes only the front and back spaces of the string, so I don't want it. Also, I tried replaceAll("\W", "") and if I use replaceAll, not only spaces but also '=' are missing from the string.

What I want is mysz2 = "name=johnage=13year=2001" What can we do about this result?

java whitespace

2022-09-22 12:17

1 Answers

st.replaceAll("\\s+","") is a command that removes all invisible characters, such as spaces and '\n'.


2022-09-22 12:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.