javascript - Regular expression to remove first part of string leading to keyword -
I think I'm about a palm-to-the-forehead moment, but I do not think this work get to do.
I have a way that I want to start it up to a certain folder (this is a separate folder, but the name of the folder will always be the same).
 Therefore, for  /path/to/templates/sometemplate.html , I want the string just  templates / sometemplate.html . ('/' Route to go '/' deleted). I am not just split on '/' and can remove the first two, because the second path is  /yet/another/path/to/templates/sometemplate.html  ....  Could.   BTW, I'm doing it in a gruntscript, so I'm looking at the Javascript string. Replace ().    How do anyone know this?       You do not really need regex here, just the  string  of the methods Use:   
 var s = '/yet/another/path/to/templates/sometemplate.html'; Var r = s.substr (s.indexOf ('/ templates /') + 1) // = & gt; Template / sometemplate.html    
 
  
Comments
Post a Comment