StepCoding

Character Classes

อ่าน [1153] หมวดหมู่: POSIX Regular Expression

POSIX ได้กำหนดชื่อชุดของอักขระไว้จำนวนหนึ่ง ซึ่งสามารถใช้ใน character class ได้ ซึ่งชุดของอักขระต่าง ๆ เหล่านั้นมีดังตาราง

ClassDescriptionExpansion
[:alnum:]Alphanumeric characters[0-9a-zA-Z]
[:alpha:]Alphabetic characters (letters)[a-zA-Z]
[:ascii:]7-bit ASCII[\x01-\x7F]
[:blank:]horizontal whitespace (space, tab)[ \t]
[:cntrl:]Control characters[\x01-\x1F]
[:digit:]Digits
[:graph:]Character ที่ใช้หมึกในการ print (non-space, non-control)[^\x01-\x20]
[:lower:]Lowercase letter[a-z]
[:print:]Printable character (เหมือน graph class แต่เพิ่ม space และ tab)[\t\x20-\xFF]
[:punct:]punctuation character เช่น period (.) และ semicolon (;)[-!"#$%&'( )*+,./:;<=>?@[\\\]^_'{|}-]
[:space:]Whitespace (newline, carriage return, tag, space, vertical tab)[\n\r\t \x0B]
[:upper:]Uppercase letter[A-Z]
[:xdigit:]Hexadecimal digit[0-9a-fA-F]
<?php
$bool = ereg('@[:digit:][:upper:]', '@3Dmn');
// true
// มีความหมายเหมือนกับ ereg('@[0-9][A-Z]', '@3Dmn')
?>

ผู้สนับสนุน