Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 contemplating the Monastery: (11)
As of 2015-07-03 11:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (51 votes), past polls