Golfreeze.packetlove.com: Life style of Golfreeze Canon400D Family kammtan.com Jazz Freebsd Unix Linux System Admin guitar Music

All about unix linux freebsd and FAQ for Packetlove.com Web hosting , Mail hosting , VoIP + IP PBX server => command , shell script ,tool , crontab => Topic started by: golfreeze on สิงหาคม 19, 2014, 05:22:12 PM

Title: regular expression เบื้องต้น
Post by: golfreeze on สิงหาคม 19, 2014, 05:22:12 PM
เป็นตัวอย่างง่ายๆ ในการใช้งาน regular expression เบื้องต้น 
สามารถนำไปประยุกต์ ในระดับ advance ได้นะครับผม

1[0-9][0-9] สามารถนำออกมาใช้ได้คือ 100 to 199
2[0-4][0-9] จะmatches 200 จนถึง 249.
25[0-5] = 250 จนถึง 255

    000..255: ^([01][0-9][0-9]|2[0-4][0-9]|25[0-5])$
    0 or 000..255: ^([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$
    0 or 000..127: ^(0?[0-9]?[0-9]|1[01][0-9]|12[0-7])$
    0..999: ^([0-9]|[1-9][0-9]|[1-9][0-9][0-9])$
    000..999: ^[0-9]{3}$
    0 or 000..999: ^[0-9]{1,3}$
    1..999: ^([1-9]|[1-9][0-9]|[1-9][0-9][0-9])$
    001..999: ^(00[1-9]|0[1-9][0-9]|[1-9][0-9][0-9])$
    1 or 001..999: ^(0{0,2}[1-9]|0?[1-9][0-9]|[1-9][0-9][0-9])$
    0 or 00..59: ^[0-5]?[0-9]$
    0 or 000..366: ^(0?[0-9]?[0-9]|[1-2][0-9][0-9]|3[0-5][0-9]|36[0-6])$