Shai Kimchi Shai Kimchi - 3 months ago 8
Javascript Question

Regex in url to find "/...#/ js

In this is an example string,

"http://jony.aaa.com/remove#/dont-remove/dont/"


What is the regex for replacing the
/remove#/
string?

I wish to remove the /...#/ part of the string. I've used (//.*?#/ig,""), but that clears everything from after the 'http:' till the '#' character

Joe Joe
Answer

I believe the following should work. It finds a /. Then not a / until it finds one #

/\/[^\/]+#/

"http://jony.aaa.com/remove#/dont-remove/dont/".replace(/\/[^\/]+#/, '')