Thursday, March 9, 2023

Regex - To find word startswith __ and endswith __ but does not contain __

 Regex to match words start with double underscore (__) and endswith double underscore (__), but should not contains double underscore (__)


Pattern: /\_\_[^_\n]{1}.*?([^_\n]+)\_\_/g


This will match __somekey__ ,  __some_key__,  but not __some__key__, insted it will match __some__