Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: A module for creating "sane" URLs from "arbitrary" titles?

by JavaFan (Canon)
on Apr 20, 2012 at 17:50 UTC ( #966224=note: print w/ replies, xml ) Need Help??


in reply to A module for creating "sane" URLs from "arbitrary" titles?

s/_-_/-/g; s/^_+//g; s/_+$//g;
Suggestion: replace the above with:
s/_(?:-_)+/_/g; s/^[-_]+//; s/[-_]+$//;


Comment on Re: A module for creating "sane" URLs from "arbitrary" titles?
Select or Download Code
Re^2: A module for creating "sane" URLs from "arbitrary" titles?
by Corion (Pope) on Apr 20, 2012 at 17:58 UTC

    Thanks for the additions.

    I'd like abc - def to become abc-def, which is why I'll be using the dash as a replacement instead of the underscore in s/_(?:-_)+/-/g; , but eliminating trailing dashes and repeated dashes is a good addition indeed. Even though it makes links to C++ and C equivalent :).

    Update: I noticed that C++ and C were already converted to the same URL fragment, C anyway.

      I meant to write s/_(?:-_)+/-/g, instead of replacing a line of _-_-_-_ with an underscore.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://966224]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2014-10-20 22:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (92 votes), past polls