Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

Regular expression to match a word starts and ends with a combination of special characters [duplicate]

Writer Sophia Terry

I am trying to write a regular expression which gives me words which starts with <!= and ends with =>. For example if there is a sentence what is your <!=name=>, the result should give me name because it matches my pattern.

I have read to use this ^ for starts with and $ for ends with, but I am not able to match a combination of special characters.

2

1 Answer

As in the comment. You can use <!=(\w+)=> because the exclamation mark and equal sign are not part of word-character class you can simply test for those characters and match the word characters between them. check:

For multiple words you can use:<!=((?:\w+| )*)=>See:

2