How can I create a SEO friendly dash-delimited url from a string?

后端 未结 12 1535
再見小時候
再見小時候 2020-12-05 19:16

Take a string such as:

In C#: How do I add \"Quotes\" around string in a comma delimited list of strings?

and convert it to:

12条回答
  •  佛祖请我去吃肉
    2020-12-05 19:59

    Solution in Perl:

    my $input = 'In C#: How do I add "Quotes" around string in a comma delimited list of strings?';
    
    my $length = 20;
    $input =~ s/[^a-z0-9]+/-/gi;
    $input =~ s/^(.{1,$length}).*/\L$1/;
    
    print "$input\n";
    

    done.

提交回复
热议问题