javascript - Capture words between two special characters -
i have string this:
"some string, $special$ string, string, string, $special$ string,..." i need capture words between 2 $ notation , put words inside <code></code> tag. result of above string should this:
"some string, <code>special</code> string, string, string, <code>special</code> string,..." how can via javascript or jquery?
you can use replace function , simple regexp:
'your text ...'.replace(/\$(.+?)\$/g, '<code>$1</code>')
Comments
Post a Comment