You need to make your regular expression non-greedy, because by default, "(.*)"
will match all of "file path/level1/level2" xxx some="xxx"
.
Instead you can make your dot-star non-greedy, which will make it match as few characters as possible:
/location="(.*?)"/
Adding a ?
on a quantifier (?
, *
or +
) makes it non-greedy.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…