Perl add around words within an HTML/XML tag

后端 未结 3 1672
一个人的身影
一个人的身影 2020-12-21 20:00

I have a file formatted like this one:

Eye color

Eye color, color

blue, cornflower blue, steely blue

3条回答
  •  被撕碎了的回忆
    2020-12-21 20:48

    perl -0777 -MWeb::Query=wq -lne'
        my $w = wq $_; my $sep = ", ";
        $w->filter("p.ul1")->each(sub {
            my (undef, $e) = @_;
            $e->html(join $sep, map {
                qq($_)
            } split $sep, $e->text);
        });
        print $w->as_html;
    '
    

提交回复
热议问题