I'm trying to get a string which matches by a regex pattern ( {$ ... } ). But I don't want the brackets and the $ sign returned.
For example
{$Testpath}/Testlink
should return
Testpath
My regex pattern looks like this at the moment:
^{\$.*}$
Try the following regex:
^\{\$\K[^}]*(?=\})
This expression mathces start-of-string ^
then a literal {
then a literal $
then it ignores those using \\K
anchor, then it matches one or more characters which aren't a }
then it looks ahead (?=\\})
for a literal }
.
You may not need the end-of-line anchor $
because the text you are trying to match might not end at the end of the string and you may not need the start-of-line ^
anchor for the opposite reason, that is the pattern you are trying to match may not be at the start of the string or line.
I think you should remove ^
and $
and use the global modifier.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.