Ciao a tutti, vorrei ottenere lo stesso risultato di

    grep -Ev '(^[[:blank:]]*$|^#)'

Ho pensato a questo:

    p = re.compile('^\s*$|^#.*', re.MULTILINE)

    \s
        Matches any whitespace character; this is equivalent to the class [
\t\n\r\f\v].

Se provo perĂ² a sostituire le righe che matchano con una stringa vuota, non
viene rimosso il new line.

    re.sub(p, '', mystring)
_______________________________________________
Python mailing list
Python@lists.python.it
https://lists.python.it/mailman/listinfo/python

Rispondere a