Slashes and hashes in Perl and metacharacters

前端 未结 6 1042
旧巷少年郎
旧巷少年郎 2020-12-22 01:32

Thanks for the previous assistance everyone!. I have a query regarding RegExp in Perl

My issue is..

I know, when matching you can write m// or // or ## (mus

6条回答
  •  眼角桃花
    2020-12-22 02:03

    There is another depth to this question about escaping forward slashes with the s modifier. With my example the capturing becomes the problem.

    $image_name =~ s/((http:\/\/.+\/)\/)/$2/g;
    

    For this to work the typo with the addition of a second forward slash, had to be captured. Also, trying to work with just the two slashes did not work. The first slash has to be led by more than one character.

    Changing "http://world.com/Photos//space_shots/out_of_this_world.jpg"
    To: "http://world.com/Photos/space_shots/out_of_this_world.jpg"

提交回复
热议问题