Finding text between tags and replacing it along with the tags

前端 未结 3 447
日久生厌
日久生厌 2021-01-07 00:00

I am using The following regex pattern to find text between [code] and [/code] tags:

(?<=[code]).*?(?=[/code])

3条回答
  •  爱一瞬间的悲伤
    2021-01-07 00:36

    You need to use back referencing, i.e. replace \[code\](.*?)\[/code\] with something like $1 which will give you what's been enclosed by the [code][/code] tags enclosed in -- for this example -- tags.

提交回复
热议问题