вторник, 19 марта 2013 г.

grep support for \d

A long time ago, when every PC had own OS, it was easy to remember, which RegEx are from POSIX standart, and which appeared only in Perl-style. Now it’s almost forgotten, and C# regexp classes don’t support POSIX character classes (like [:digit:]).

That’s why the debugging of a simple bash script is so difficult. grep is older then a lot of his users, he remembers all of these times and needs -P for Perl mode and ‘\d’ for digits support.

That’s how

ls | grep -e "[0-9][0-9].[0-9][0-9].md"

becames:

ls | grep -Pe "\d{2}.\d{2}.md"

Комментариев нет:

Отправить комментарий