Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the purpose of (dollar) slashy string in Groovy

Tags:

groovy

Why there are (dollar) slashy strings since they can be interchanged with quote ones and then can be spared for other syntax usage? Is there any proof of their irreplaceability?

like image 839
Xizhi Avatar asked Aug 10 '15 04:08

Xizhi


1 Answers

If you're defining a regular expression pattern, then slashy strings are useful as you don't need to escape backslashes, e.g.

/\s+/

However, if you need a forward slash in your pattern, you'd need a dollar slashy string, e.g.

$/([a-z]+)/([a-z]+)/$

Or see the docs

like image 159
tim_yates Avatar answered Nov 15 '22 07:11

tim_yates