tailieunhanh - Beginning Regular Expressions 2005 phần 4

Nếu kết hợp được tìm thấy cho sự xuất hiện đầu tiên của \ d, các xét nghiệm biểu hiện động cơ thường xuyên nếu các nhân vật tiếp theo là một số chữ số. Nếu phù hợp, một nhân vật thứ ba là thử nghiệm để xác định nếu nó phù hợp với \ d siêu ký tự cho một chữ số. Nếu ba nhân vật kế tiếp là mỗi một chữ số, có một trận đấu thường xuyên | Lookahead and Lookbehind 6. Click the Find First icon and then click the Find Next icon twice observing each time what character sequence is or is not matched. Figure 8-7 shows the appearance after the Find Next icon has been clicked twice. With the modification of the regular expression all three occurrences of the character sequence Andrew now match. Figure 8-7 7. Now that you know that each occurrence of the relevant string matches you can modify the regular expression to create two groups between which you can insert the desired apostrophe to make Andrew s possessive. Modify the regular expression in the Match tab to Andrew s b . 8. Using the Find First and Find Next icons confirm that all three occurrences of the slightly modified desired character sequence Andrews match. 9. Click the Replace tab. In the lower pane on the Replace tab type 1 2. 10. On the Test tab click the Replace All icon and inspect the results in the lower pane on the Test tab. You may need to adjust the window size to see all the results. Figure 8-8 shows the appearance after this step. 207 Chapter 8 Figure 8-8 How It Works The pattern Andrew s s b matches the character sequence Andrew followed by either s and a space character or by s and a word boundary. In the first line the character sequence Andrew is followed by s and a space character so it satisfies the first lookahead constraint. Because the match is successful and the lookahead constraint is satisfied there is a match for the whole regular expression. In the second line the character sequence Andrew is followed by s and a period character. The second lookahead constraint is satisfied. On the third line the character sequence Andrew is followed by an s and then a question mark. Because the question mark is in neither lookahead the lookahead constraint is not satisfied. When the regular expression pattern is changed to Andrew s b when Andrew is matched the lookahead constraint is an s followed by a word boundary. There is a word .

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.