Professional Information Technology-Programming Book part 114

Tham khảo tài liệu 'professional information technology-programming book part 114', 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ả | 123-456-7890 1234567890 123 456 7890 This pattern seemed to work but why As before checks for the start of a parentheses pair but this time the results are enclosed within parentheses so as to be able to create a subexpression. d 3 matches the three-digit area code. 1 - matches either or - depending on whether the condition is satisfied. If 1 exists meaning that an open parenthesis was found then must be matched otherwise - must be matched. This way parentheses must always be paired and the hyphen separating the area code from the number is matched only if parentheses are not used. Patterns can start to look very complex when conditions are embedded and this can make troubleshooting very difficult. It is generally a good idea to build and test small parts of the expression and then put them together. Lookaround Conditions A lookaround condition allows for expressions to be executed based on whether a lookahead or lookbehind operation succeeded. The syntax for lookaround conditions is much the same as it is for backreference conditions except that the backreference the number inside of the parentheses is replaced by a complete lookaround expression. Note Refer to Lesson 9 Looking Ahead and Behind for details on using lookaround processing. As an example consider . ZIP codes. These may be five-digit ZIP codes formatted as 12345 or ZIP 4 codes formatted as 12345-6789. The hyphen is used only if the additional four digits are present. Here s one solution 11111 22222 33333- 44444-4444 d 5 - d 4 11111 22222 33333- 44444-4444 d 5 matches the first five digits and - d 4 matches a hyphen followed by four more digits if they all exist. But what if you wanted to not match any badly formatted ZIP codes The third line in the example has a trailing hyphen that probably should not be there. The preceding pattern matched the digits without the hyphen but how could you not match that entire ZIP code because it is badly formatted This example may seem a bit contrived but it does

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
36    94    1    02-07-2024
Đã 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.