in reply to Converting a passage of Spanish into hyphens and spaces

See perlre and perlrecharclass for what the parts in a regular expression mean.

\S means "any non-whitespace", but you don't want that, you want "any alphabetical character". I don't know what encoding your text is in, but if it is Latin-1, the following will work:

perl -pi -e 's/[a-z]/-/gi'

If your text file is encoded as (for example) UTF-8 or Unicode, I'm not sure if a oneliner will work. The following is untested but could work:

perl -CIO -pi -e 's/[[:alpha:]]/-/gi'

Replies are listed 'Best First'.
Re^2: Converting a passage of Spanish into hyphens and spaces
by UKhombre (Initiate) on Sep 13, 2015 at 12:44 UTC
    Thank you Corion. My piece of text was saved in UTF-8. I couldn't get either command to work. I tried saving a text file in Western ISO Latin 1. Is that the same as Latin-1? Anyway I couldn't get that to work either. Dumb question: if I pasted some error messages does that tell you everything you need to know?

      I'm not sure if that will tell me everything I need to know, but the error messages will certainly help diagnose it better.

        I've just tried the Unicode one again and this time I got it to work. I don't know what I did differently in terms of my typing in your code plus the file name.

        Recuerdo igual que si fuera hoy el día que llegué. Había hecho el viaje en tren con otros cinco compañeros novatos, y al bajar en la estación fuimos al hotel Condal, donde habíamos reservado habitaciones.

        -------- ----- --- -- ----- --- -- -í- --- -----é. ---í- ----- -- ----- -- ---- --- ----- ----- -----ñ---- -------, - -- ----- -- -- ------ó- ------ -- ----- ------, ----- ---í---- --------- ------------.

        As you can see there's still the letters with accents but if that can't be changed no worries and thank you very much for what you've done.