TAILIEUCHUNG - Học JavaScript qua ví dụ part 85

Metasymbols Metasymbols cung cấp một cách khác để đại diện cho một lớp nhân vật. Ví dụ, thay vì đại diện một số là [0-9], nó có thể được biểu diễn như là \ d, và thay thế cho đại diện-resenting một nonnumber [^ 0-9] là \ D. Metasymbols được dễ dàng hơn để sử dụng và để loại hơn metacharacters | Getting Control The Metacharacters 741 EXAMPLE continued script type text javascript Negation within a Character Class 1 var reg_expression A0-9 2 var textString prompt Type a string of text 3 var result textString Returns true or false result br if result b The reg_ex A0-9 matched the string textstring . br else alert No Match script body html EXPLANATION 1 The caret inside a character class when it is the first character after the opening bracket creates a negation meaning any character not in this range. This regular expression matches a string that does not contain a number between 0 and 9. 2 User input is assigned to the variable textString. In this example abc was entered. 3 The regular expression test method will return true because the string abc does not contain a character ranging from 0 to 9 see Figure . Figure The user entered abc. It contains a character that is not in the range between 0 and 9. Metasymbols Metasymbols offer an alternative way to represent a character class. For example instead of representing a number as 0-9 it can be represented as d and the alternative for representing a nonnumber A0-9 is D. Metasymbols are easier to use and to type than metacharacters. From the Library of 742 Chapter 17 Regular Expressions and Pattern Matching Table Metasymbols Symbol What It Matches Character Class d One digit 0-9 D One nondigit A0-9 s One whitespace character tab space newline carriage return formfeed vertical tab S One nonspace character w One word character A-Za-z0-9_ W One nonword character AA-Za-z0-9 EXAMPLE html head title The Digit Meta Symbol title head body script type text javascript 1 var reg_expression 6 d d 2 var textString prompt Type a string of text 3 var result textString Returns true or false result br if result b The regular expression 6 d d matched the string textstring . br .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.