Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
166 views
in Technique[技术] by (71.8m points)

Removing whitespace from strings in Groovy

I have a string like

String  str = "My name is Monda"

How can I achieve a string like

str  = "MynameisMonda"
question from:https://stackoverflow.com/questions/18936452/removing-whitespace-from-strings-in-groovy

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use the replaceAll() function.

For your case:

replaceAll("\s","")

where s means any whitespace (such as a space character).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...