16 Temmuz 2019 Salı

bah kodlama - regular expression

Giriş
Standart POSIX düzenli ifadeleri şöyle.
[[:alnum:]]   Alphanumeric characters
[[:alpha:]]   Alphabetic characters
[[:blank:]]   Space and tab
[[:cntrl:]]   Control characters
[[:digit:]]   Digits
[[:graph:]]   Visible characters (anything except spaces and control characters)
[[:lower:]]   Lowercase letters
[[:print:]]   Visible characters and spaces (anything except control characters)
[[:punct:]]   Punctuation (and symbols).
[[:space:]]   All whitespace characters, including line breaks
[[:upper:]]   Uppercase letters
[[:xdigit:]]  Hexadecimal digits
Standart olmayanlar şöyle.
[[:ascii:]]   ASCII characters
[[:word:]]    Word characters (letters, numbers and underscores)
Örnek
Şöyle yaparız.
if [[ $var =~ [[:space:]] ]]; then
    echo "'$var' contains whitespace"
fi
Örnek
Şöyle yaparız.
case $var in 
    *[[:space:]]*) echo "'$var' contains whitespace";;
esac
Örnek
Şöyle yaparız.
[[ $line =~ [[:space:]]*?(a)b ]]


Hiç yorum yok:

Yorum Gönder