Background
Looking to replace periods with dollar signs only within text that is delimited by dollar signs (never spanning lines). For example:
Names: $annie.bettie.cindy.dannie.ellie$. Only $a$ names. $a.b.c.d.e.f$.
Problem
The following regex almost works, but is too simple:
/([[:alnum:]])\.([[:alnum:]])/g
If a match exists outside of the delimiters ($
), then too much will be replaced.
The following regex:
/\$.*?\$/g
Matches and groups the delimited strings:
Names: $annie.bettie.cindy.dannie.ellie$. Only $a$ names. $a.b.c.d.e.f$.
Question
How do I combine the two regular expressions so that the periods can be replaced with another string? For example:
Names: $annie.bettie.cindy.dannie.ellie$. Only $a$ names. $a.b.c.d.e.f$.
Ultimately will become:
Names: `r v$annie$bettie$cindy$dannie$ellie`. Only `r v$a` names. `r v$a$b$c$d$e$f`.
The trouble I'm having is matching the delimited dots.
The regular expression will be piped into sed from a terminal running bash.