Regular expression replace a word by a link

后端 未结 7 2409
走了就别回头了
走了就别回头了 2020-12-18 11:51

I want to write a regular expression that will replace the word Paris by a link, for only the word is not ready a part of a link.

Example:

    i\'m l         


        
7条回答
  •  旧巷少年郎
    2020-12-18 12:18

    If you weren't limited to using Regular expressions in this case, XSLT is a good choice for a language in which you can define this replacement, because it 'understands' XML.

    You define two templates: One template finds links and removes those links that don't have "Paris" as the body text. Another template finds everything else, splits it into words and adds tags.

提交回复
热议问题