tailieunhanh - Professional Information Technology-Programming Book part 113

Tham khảo tài liệu 'professional information technology-programming book part 113', 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ả | Without word boundaries the 0 in 30 was also matched. Why Because there is in front of it. Enclosing the entire pattern within word boundaries solves this problem. Summary Looking ahead and behind provides greater control over what is returned when matches are made. The lookaround operations allow subexpressions to be used to specify the location of text to be matched but not consumed matched but not included in the matched text itself . Positive lookahead is defined using and negative lookahead is defined using . Some regular expression implementations also support lookbehind using and negative lookahead using . Lesson 10. Embedding Conditions A powerful yet infrequently used feature of the regular expression language is the capability to embed conditional processing within an expression. This lesson will explore this topic. Why Embed Conditions 123 456-7890 and 123-456-7890 are both acceptable presentation formats for North American phone numbers. 1234567890 123 -456-7890 and 123-4567890 all contain the correct number of digits but are badly formatted. How could you write a regular expression to match only the acceptable formats and not any others This is not a trivial problem consider this obvious solution 123-456-7890 123 456-7890 123 -456-7890 123-456-7890 1234567890 123 456 7890 d 3 - d 3 - d 4 123-456-7890 123 456-7890 123 -456-7890 123-456-7890 1234567890 123 456 7890 matches an optional opening parenthesis notice that must be escaped d 3 matches the first three digits matches an optional closing parenthesis - matches an optional hyphen and d 3 - d 4 matches the remaining seven digits separated by a hyphen . The pattern correctly did not match the last two lines but it did match the third and fourth both of which are incorrect the third contains both and - and the fourth has an unmatched parenthesis . Replacing - with - will help eliminate the third line by allowing only or - but not both but the fourth line is a problem. The pattern needs to match only if

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.