I am trying to have a VS code snippets.For generating java class.I am terrible with regex. As explained in here followed the instruction.
what i am trying is to extract the package name from my project path
/home/bspl/Projects/SpringBoot/mdmssa/src/main/java/com/mdmssa/controller
which should be like
com.mdmssa.controller
the keyword here is java which will remain same in every project.
Till now i came up with this following another thread in stackoverflow
"${TM_FILEPATH/.*[\\/](.*[\\/].*)$/$1/}"
Help would be much appreciated.
${TM_DIRECTORY/.*[\\/]java\\/(.*[\\/].*)$/$1/}i can capture the group but was not able to do a transformation on captured group i.ecom/mdmssa/controllerhas to be transformed tocom.mdmssa.controllerAny idea on that..path.replaceAll(".+/(\\w+)/(\\w+)/(\\w+$)", "$1.$2.$3");On the example path you give, it returnscom.mdmssa.controller${TM_DIRECTORY/.*[\\/]java\\/(.*[\\/].*)$/${1/[\\]/\./}/}and it doesn't work.. and regex inpath.replaceAll(".+/(\\w+)/(\\w+)/(\\w+$)", "$1.$2.$3")will work in most of my projects only drawback it is limited to 3 level of directory..