Professional Information Technology-Programming Book part 98

Tham khảo tài liệu 'professional information technology-programming book part 98', 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ả | Summary Metacharacters and are used to define sets of characters any one of which must match OR in contrast to AND . Character sets may be enumerated explicitly or specified as ranges using the - metacharacter. Character sets may be negated using A this forces a match of anything but the specified characters. Lesson 4. Using Metacharacters Metacharacters were introduced in Lesson 2 Matching Single Characters. In this lesson you ll learn about additional metacharacters used to match specific characters or character types. Escaping Revisited Before venturing deeply into the world of metacharacters it is important to understand escaping. Metacharacters are characters that have special meaning within regular expressions. The period . is a metacharacter it is used to match any single character as explained in Lesson 2 . Similarly the left bracket is a metacharacter it is used to mark the beginning of a set as explained in Lesson 3 Matching Sets of Characters . Because metacharacters take on special significance when used in regular expressions these characters cannot be used to refer to themselves. For example you cannot use a to match or . to match . Take a look at the following example. A regular expression is being used to attempt to match a JavaScript array containing and var myArray new Array if myArray 0 0 myArray 0 var myArray new Array if myArray 0 0 In this example the block of text is a JavaScript code snippet or a part of one . The regular expression is the type that you would likely use within a text editor. It was supposed to have matched the literal text myArray 0 but it did not. Why not and are regular expression metacharacters that are used to define a set but not the characters and . As such myArray 0 would match myArray followed by one of the members of the set and 0 is the only member. Therefore myArray 0 would only ever match myArray0. As explained in Lesson 2 metacharacters can be escaped by preceding them with a backslash. Therefore . matches . and

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
192    73    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.