Since you have "open" and "close" markers, the regex expression would obviously be built around this form:
[head-marker: $] [the content you are interested in: anything] [tail-marker: /$]
so, with addition of a parentheses to form a capturing group:
$(.*)$
However, two problems here: *
expressions are greedy (and you dont want it to be, as you want all smallest matches possible) - so it has to be weakened, and also the $
is a special character in regex, so it has to be escaped:
\$(.*?)/\$
this forms almost-good expression. It will however falsely match agains such input:
aaaaa/$bbbbb/$ccccc -> bbbbb
because the "head-marker" can skip the slash and hit the first dollar sign what most probably you wouldn't want. Hence, some lookbehind would be useful here too:
(?!</)\$(.*?)/\$
The ?!<XXXX
instructs to match only if XXXX does not precede the potential match.
See also MSDN: Regex syntax and operators
edit: actually Arie's suggestion is much simplier as it doesn't use capturing group. Note the small difference though: Arie's example explicitely fobids the data to contain a dollar sign, so ABCD$-$ToBeFe$tched1/$-
will result in tched1
not ToBeFe$tched1
. If you need the latter, just change the inner [^$]
part. Think and pick what you actually need!