I have a string, and I need to remove a substring from the string. The substring is enclosed in identifiers (e.x [[1]] substring [[\1]]).
String e.x: [[1]] abc [[\1]] [[2]] pqr [[\2]] xyz [[3]] rst [[\3]] [[5]] ijk [[\5]]
I expect to get [[1]] abc [[\1]]
from string:
[[1]] abc [[\1]] [[2]] pqr [[\2]] xyz [[3]] rst [[\3]] [[5]] ijk [[\5]]
if I know the substring abc
I have tried this solution: /\[\[(\d)\]\] pqr \[\[\\\1\]\]/gm
but I need to provide dynamic text.
(e.x if I want to remove abc
, i need to find the text enclosed in the identifiers in the string and remove it)