Capture words between two special characters

hamed

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?

Anton Savchenko

You can use replace function and simple regexp:

'your text ...'.replace(/\$(.+?)\$/g, '<code>$1</code>')

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

using regexp_substr to capture all characters between two words (including the front and end of the string

分類Dev

Matching string between two markers that are filepaths and contain special characters

分類Dev

How to extarct the string words and special characters between curly brackets in php preg_match

分類Dev

fetch string between special 2 characters

分類Dev

Python regex: removing all special characters and numbers NOT attached to words

分類Dev

Getting everything between two characters

分類Dev

RegEx for matching special chars in between two numbers

分類Dev

Using regex to capture everything between two asterisks

分類Dev

cosine similarity between two words in a list

分類Dev

Extract a word between two words javascript

分類Dev

Regex JS: Searching between two same words

分類Dev

removing string between two words in unix

分類Dev

How to get the text between two words in R?

分類Dev

To identify repeated words and get the distance between two words as a list in python

分類Dev

print words between two particular words in a given string

分類Dev

Print an array between two given characters

分類Dev

If between two different characters in a text file, Python

分類Dev

How to extract a string between two characters?

分類Dev

How to remove all whitespace between a two characters?

分類Dev

Regex: Match all characters between two strings

分類Dev

Extract character between the first two characters

分類Dev

Store text between two characters in a array

分類Dev

Variable length substring between two characters

分類Dev

Grep words with special symbols

分類Dev

Extract text between two words from all files in a folder in R

分類Dev

Replace file text between two words across multiple lines

分類Dev

Counting shared words between strings in two columns of a data frame

分類Dev

Using sed / awk to change words between two patterns

分類Dev

Escaping special characters in elasticsearch

Related 関連記事

  1. 1

    using regexp_substr to capture all characters between two words (including the front and end of the string

  2. 2

    Matching string between two markers that are filepaths and contain special characters

  3. 3

    How to extarct the string words and special characters between curly brackets in php preg_match

  4. 4

    fetch string between special 2 characters

  5. 5

    Python regex: removing all special characters and numbers NOT attached to words

  6. 6

    Getting everything between two characters

  7. 7

    RegEx for matching special chars in between two numbers

  8. 8

    Using regex to capture everything between two asterisks

  9. 9

    cosine similarity between two words in a list

  10. 10

    Extract a word between two words javascript

  11. 11

    Regex JS: Searching between two same words

  12. 12

    removing string between two words in unix

  13. 13

    How to get the text between two words in R?

  14. 14

    To identify repeated words and get the distance between two words as a list in python

  15. 15

    print words between two particular words in a given string

  16. 16

    Print an array between two given characters

  17. 17

    If between two different characters in a text file, Python

  18. 18

    How to extract a string between two characters?

  19. 19

    How to remove all whitespace between a two characters?

  20. 20

    Regex: Match all characters between two strings

  21. 21

    Extract character between the first two characters

  22. 22

    Store text between two characters in a array

  23. 23

    Variable length substring between two characters

  24. 24

    Grep words with special symbols

  25. 25

    Extract text between two words from all files in a folder in R

  26. 26

    Replace file text between two words across multiple lines

  27. 27

    Counting shared words between strings in two columns of a data frame

  28. 28

    Using sed / awk to change words between two patterns

  29. 29

    Escaping special characters in elasticsearch

ホットタグ

アーカイブ