In a perl string, how can I replace a unicode em dash with 2 ascii hyphens? -


i first tried find in line using:

    $w = index($line, "\x{2014}"); 

i got no syntax error, $w never >= 0.

i tried:

    $line =~ s/\x{2014}/--/g; 

and didn't work either, ie: no changes made.

what's simplest way make swap?

if explained in prior posts, didn't see where.

works me:

#!/bin/perl -w  use feature 'unicode_strings'; use utf8;  $line = "first — , second"; $line =~ s/\x{2014}/--/g; print("$line\n"); # => first -- , second 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -