Thread Was matcht ^ ? -- Problem Windows/Linux (11 answers)
Opened by Prosa at 2009-07-18 11:18

Linuxer
 2009-07-18 12:44
#123338 #123338
User since
2006-01-27
3882 Artikel
HausmeisterIn

user image
Hi,

bei dem Regex ist es der DOS-Umbruch, der hier Probleme macht, nicht der Anker ^.

Code: (dl )
1
2
3
4
# zwei zeilen, eine mit linux, eine mit dos umbruch
# ausgabe mit print wenn der regex matchen konnte
$ echo -e "1234,5678\n2345,6789\r\n" | perl -nle 'print "$1 $2" if m/^(\d+),(\d+)$/;'
1234 5678


Wie überträgst Du die Datei von WinDOS auf Deinen Server?
Mit FTP? Dann stell sicher, dass Du die Datei im ASCII-Modus überträgst.

Infos zu Regex und ^ finden sich in:

http://perldoc.perl.org/perlretut.html
http://perldoc.perl.org/perlrequick.html
http://perldoc.perl.org/perlre.html

Die Info ist allerdings in einen Text eingebettet, z.B.:

Quote
To do this, we would use the anchor metacharacters ^ and $ . The anchor ^ means match at the beginning of the string and the anchor $ means match at the end of the string, or before a newline at the end of the string.


meine Beiträge: I.d.R. alle Angaben ohne Gewähr und auf Linux abgestimmt!
Die Sprache heisst Perl, nicht PERL. - Bitte Crossposts als solche kenntlich machen!

View full thread Was matcht ^ ? -- Problem Windows/Linux