Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does regex "\\p{Z}" mean?

Tags:

I am working with some code in java that has an statement like

String tempAttribute = ((String) attributes.get(i)).replaceAll("\\p{Z}","")

I am not used to regex, so what is the meaning of it? (If you could provide a website to learn the basics of regex that would be wonderful) I've seen that for a string like

ept as y it gets transformed into eptasy, but this doesn't seem right. I believe the guy who wrote this wanted to trim leading and trailing spaces maybe.

like image 442
BRabbit27 Avatar asked May 12 '15 15:05

BRabbit27


1 Answers

It removes all the whitespace (replaces all whitespace matches with empty strings).

A wonderful regex tutorial is available at regular-expressions.info. A citation from this site:

\p{Z} or \p{Separator}: any kind of whitespace or invisible separator.

like image 107
Alex Shesterov Avatar answered Oct 21 '22 02:10

Alex Shesterov