need some regex help javascript -


i hoping can me, using javascript , asp

i have string /folder1/folder2/pagename.asp

i need regex strip /pagename.asp string

pagetype.replace(/\/.*?\.asp/ig, ''); 

the regex above halfway there problem strippes beginning / between / , .asp

how make regex lazy strip between last / , .asp?

any appreciated!

try this:

pagetype.replace(/\/[^\/]*\.asp/ig, ''); 

i've used [^\/] group represent symbol not equal /.


Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -