tailieunhanh - Professional Information Technology-Programming Book part 118

Tham khảo tài liệu 'professional information technology-programming book part 118', 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ả | localhost is . This pattern uses a series of nested subexpressions. The first is d 1 2 1 d 2 2 0-4 d 25 0-5 . a set of four nested subexpressions. d 1 2 matches any one- or two-digit number or numbers 0 through 99. 1 d 2 matches any three-digit number starting with 1 1 followed by any 2 digits or numbers 100 through 199. 2 0-4 d matches numbers 200 through 249. 25 0-5 matches numbers 250 through 255. Each of these subexpressions is enclosed within another subexpression with an between each so that one of the four subexpressions has to match but not all . After the range of numbers comes . to match . and then the entire series is enclosed into yet another subexpression and repeated three times using 3 . Finally the range of numbers is repeated this time without the trailing . to match the final IP address number. The pattern thus validates the format of the string to be matched that it is four sets of numbers separated by . and validates that each of the numbers has a value between 0 and 255. Note This IP address example is explained in detail in Lesson 7 Using Subexpressions. URLs URL matching is a complicated task or rather it can be complicated depending on how flexible the matching needs to be. At a minimum URL matching should match the protocol probably http and https a hostname an optional port and a path. http blog https 80 blog http http ben password@ http localhost ab 1 c 2 http localhost 8500 https - w. d w _. http blog https 80 blog http http ben password@ http localhost ab 1 c 2 http localhost 8500 https matches http or https the makes the s optional . - w. matches the hostname. d matches an optional port as seen in the second and sixth lines in the example . w _. matches the path the outer subexpression matches if one exists and the inner subexpression matches the path itself. As you can see this