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

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -