javascript - Removing file extension and special characters -


hi trying remove file extension , special chracters problem slight difficult thats existing code

<script> var pathname = window.location.pathname; pathname = pathname.replace(/[^a-za-z0-9]/g,' '); window.location="http://mimuz.com/search.php?keywords="+pathname;  </script> 

in path name there 3 portions forexample

/videos-of-stars-and-stellites-etc_fe5eb9bf1.html 

to best explain url

videos-of-stars-and-stellites-etc = video name

than comes underscore _

and than

fe5eb9bf1= unique video id

than lastly

.html = extension

what want want remove slashes, hyphens, dots , replace them spaces , lastly want remove _fe5eb9bf1.html type of porting urls idea ?

so @ end result this

videos of stars , stellites etc 

pathname.replace(/_[^.]+.[a-z]+$/, '').replace(/[^a-za-z0-9]/g,' '); 

here's fiddle: http://jsfiddle.net/bpvbk/


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -