I'm trying to select all characters around some word, but not the word itself with regex in javascript.
(Then I will delete the selected part in JS myself.)
My string is: [id='s_change_b']
I want to select bold and italic part only:
[id='
s_change_b
']
I tried this Regular Expression, but it also selects word inside it.
/\[id='(.*?)'\]/
How can I only select characters around it? I only need Regular Expression part. Thanks in advance!
(\[id=')[^\[\]]*('\])
regex101.com/r/1DzGzZ/1 – The fourth birdreplace(/(\[id=')(.*?)('])/g, '<b>$1</b>$2<b>$3</b>')
– Wiktor Stribiżew