I have a string like this:
"some string, some $special$ string, some string, some string, some $special$ string,..."
I need to capture all words between two $
notation and put words inside <code></code>
tag. The result of above string should be this:
"some string, some <code>special</code> string, some string, some string, some <code>special</code> string,..."
How can I do this via javascript or jquery?
You can use replace function and simple regexp:
'your text ...'.replace(/\$(.+?)\$/g, '<code>$1</code>')
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加