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

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -