tailieunhanh - Beginning Regular Expressions 2005 phần 7

Bởi vì các biến myRegExp được tạo ra với không ai trong số các hiệp hội quy định, mỗi ignoreCase, toàn cầu, và các thuộc tính multiline chứa các giá trị Boolean sai. Các tài sản nguồn chứa các giá trị của mô hình, \ d +, được chứa đựng trong tuyên bố chuyển nhượng cho biến myRegExp. | Regular Expressions in JScript and JavaScript Because the myRegExp variable was created with none of the associations specified each of the global ignoreCase and multiline properties contains the Boolean value false. The source property contains the value of the pattern d which was contained in the assignment statement for the myRegExp variable. The lastindex property contains the value of the character position following the previous match. When the test text was Hello 99 the value of the lastIndex property was 8 because the match the character sequence 9 9 consisted of character positions 6 and 7. When the test text was 9 9 Hello the value of the lastIndex property was 2 because the match 9 9 consisted of character positions 0 and 1 because indexing starts at 0. The test Method of the RegExp Object The test method of the RegExp object tests whether or not a string matches a pattern. If there is at least one match the test method returns the Boolean value true. If there is no match the test method returns the Boolean value false. You saw in the preceding example situations that the value true was returned because both test character sequences Hello 99 and 99 Hello contained at least one numeric digit and therefore matched the pattern d which matches one or more numeric digits. If you enter a character sequence that contains no numeric digit the value returned by the test method when matching the pattern d will be the Boolean value false. The exec Method of the RegExp Object The exec method of the RegExp object is powerful flexible and potentially confusing. First let s look at using the exec method when the pattern is used with the g attribute. In other words the value of the global property of the RegExp object will contain the Boolean value true. Try It Out With global Property true The test file contains the following markup and code html head title RegExp exec Method Example with global attribute set. title script language javascript .

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.