yalkris
yalkris

Reputation: 2695

How to make scala regex findAllIn escape characters enclosed inside single quotes

I need to count number of arguments using regex for an i18n project like below

new Regex("\\{.*?\\}").findAllIn("{1},{2},{3} '{'4'}'").length 

should return 3 instead of four. Can someone help with my regex?

Upvotes: 0

Views: 296

Answers (1)

Sina Iravanian
Sina Iravanian

Reputation: 16286

If arguments can contain only digits, replace the pattern with this one:

\\{\\d+\\}

Upvotes: 3

Related Questions