Issue
networks[0]/site[9785d8e8-9b1f-3fc0-8271-6e32f58fb725]/equipment/location[144ae20e-be33-32e2-8b52-798e968e88b9]
The objective is to get the 9785d8e8-9b1f-3fc0-8271-6e32f58fb725 from above string. I have written the regex as below. But its giving the output as "location".
.*\\/([^\\/]+)\\[.*\\]$
Could any one suggest me the proper regex to get the 9785d8e8-9b1f-3fc0-8271-6e32f58fb725 from above string.
Solution
You can just use site\[(.+?)\]
. See the test.
P.S. You current expression is actually doing the following:
- Pass whatever
.*
- Unless you encounter
/
- then capture any sequence after
/
not containing:\
,/
- which in turn is followed by
[]
with whatever content straight away and residing at the very end of the string.
So the only matching part is location
Answered By - Alexey R.
Answer Checked By - Candace Johnson (JavaFixing Volunteer)