I am trying to write a VScode snippet to convert the filename to a unique string so that it can be used in the header's include pragma.
For example, if the filename is Account-Manager.hpp then I want to convert it into __ACCOUNT_MANAGER_HPP__.
To covert filename to all caps, "${TM_FILENAME/(.*)/${1:/upcase}/}",
To replace all - and . to _, "${TM_FILENAME/(.*)/${1:/upcase}/}",
Not able to combine two regexes into a single one!
Answer:
__${TM_FILENAME/(^|[-.])([^-.]+)/${1:+_}${2:/upcase}/g}__"
Found the solution as below:
The double operation can be done with multiple captures as below:
__${TM_FILENAME/(^|[-.])([^-.]+)/${1:+_}${2:/upcase}/g}__"