Java regex path extraction

Slobodan Vrhovac :

I have String in the format:

String evaluationString = "MATH(($.customString.customString.cuStromString + $.customString.customString)*5% - ($.customString + 5%))"

I have problem to extract path value ($.string.string or $.string or $.string.string.string) with regex. I need to switch that path with a value from a path Can someone help?

Kasper Davidsen :

How about this:

(\$(?:.\w+)+)

It begins matching from $ and includes as many sequences of . followed by letters, numbers, or underscores as necessary. When something else (spaces or operators) appear, the match stops.

Remember to escape the escape character itself by using \\ when writing this within Java code.

Demo here.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=28880&siteId=1