简体   繁体   中英

Find and replace regex for visual studio

I have a lot of strings like this to find and replace in visual studio:

$CLICKTHRU:Dark-Shadows-Reunion-Experience$
$CLICKTHRU:Pirahna-3DD-Experience$
$CLICKTHRU:The-Dictator$

I've been trying to follow the instructions on msdn here but I have got a little stuck.

Here's my shameful attempt so far:

\$CLICKTHRU\:[:a|-|\$]

Tested on the first string that only matches

$CLICKTHRU:D

Could anyone give me a hand with a brief explanation?

Use this pattern: \\$CLICKTHRU\\:[^$]+\\$

The $ is a metacharacter so it must be escaped to be interpreted literally, except when it occurs within a character class. In Visual Studio the colon has to be escaped as well.

  • \\$CLICKTHRU\\: pretty straightforward given the above explanation. This is mostly matching literal characters.
  • [^$]+ is a negative character class, since it starts with a ^ inside the square brackets. It matches any character that is not a $ character. The + indicates that the pattern should be matched one or more times.
  • \\$ match the ending $ character.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM