James South
James South

Reputation: 10635

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?

Upvotes: 1

Views: 256

Answers (1)

Ahmad Mageed
Ahmad Mageed

Reputation: 96477

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.

Upvotes: 1

Related Questions