Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo tài liệu 'professional information technology-programming book part 103', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | MARGINWIDTH 0 MARGINHEIGHT 0 TOPMARGIN 0 LEFTMARGIN 0 xdigit matches a hexadecimal character and 6 repeats that POSIX class 6 times. This would have worked just as well using 0-9A-Fa-f 6 . Range Interval Matching Intervals may also be used to specify a range of values a minimum and a maximum number of instances that are to be matched. Ranges are specified as 2 4 which would mean a minimum of 2 and a maximum of 4 . An example of this is a regular expression used to validate the format of dates 4 8 03 10-6-2004 2 2 2 01-01-01 d 1 2 - d 1 2 -V d 2 4 4 8 03 10-6-2004 2 2 2 01-01-01 The dates listed here are values that users may have entered into a form field values that must be validated as correctly formatted dates. d 1 2 matches one or two digits this test is used for both day and month d 2 4 matches the year and -V matches either - or as the date separator. As such three dates were matched but not 2 2 2 which fails because the year is too short . Tip The regular expression used here escapes as V. In many regular expression implementations this is unnecessary but some regular expression parsers do require this. As such it is a good idea to always escape . It is important to note that the preceding pattern does not validate dates invalid dates such as 54 67 9999 would pass the test. All it does is validate the format the step usually taken before checking the validity of the dates themselves . Note Intervals may begin with 0. Interval 0 3 means match zero one two or three instances. As seen previously matches zero or one instance of whatever precedes it. As such is functionally equivalent to 0 1 . At Least Interval Matching The final use of intervals is to specify the minimum number of instances to be matched without any maximum . The syntax for this type of interval is similar to that of a range but with the maximum omitted. For example 3 means match at least 3 instances or stated differently match 3 or more instances. Let s look at an example which combines much of