Snippets tagged "string" Snippets tagged "string"

Extraire toutes les chaînes d'un fichier binaire

En fait, c'est tout bête (mais qu'est ce que ça peut être utilie !) :

$ strings /usr/bin/iconv 
Written by %s.
char
UCS-4
conversion from %s unsupported
conversion to %s unsupported
conversion from %s to %s unsupported
try '%s -l' to get the list of supported encodings
[...]
by Nicolas Perriault on 2008-04-23, tagged cli  extract  linux  string 

Changer les caractères <CR> en <LF>

Convertir rapidement et simplement les caractères \r en \n :

$ perl -pi -e 's#\r#\n#gs' /path/to/file
by Nicolas Perriault on 2007-01-15, tagged character  cli  linux  perl  string 
(1 comment)

Effacer les lignes vides d'un fichier

$ sed '/^$/d' fichier.txt
by Nicolas Perriault on 2006-12-09, tagged cli  linux  sed  string 

Obtenir un tableau de caractères depuis une chaîne en PHP4

En php5 on a str_split : http://fr.php.net/manual/fr/function.str-split.php

Et en PHP4 :

$chars = preg_split('#(?<=.)(?=.)#s', $string);
by Nicolas Perriault on 2006-10-11, tagged array  php  string 
(3 comments)