i struggling regexp matching. in case need select characters except between specific tags. text like:
lorem ipsum dolor sit amet [original]don't select this[/original], sit epicuri qualisque id.
'and want lorem ipsum dolor sit amet' + , 'sit epicuri qualisque id' selected text. i've tried selecting characters excluding phrase don't it. if put groups first occurence works, if more tags present can't desired result.
any tips on how can achieve this?
you can make use of capturing groups , grab in capturing group want.
^((?:(?!\[original\]).)+)\[original\](?:(?!\[\/original\]).)+\[\/original\](.+)$
this put before tag in capturing group 1, , after in capturing group 2. whole match matches entire line, tag , between not being capturing in group.
note: won't work if there more 1 tag. if want that, please edit question reflect that.
tested on regex101
Comments
Post a Comment