tailieunhanh - Professional Information Technology-Programming Book part 110

Tham khảo tài liệu 'professional information technology-programming book part 110', 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ả | Caution As noted previously you will need to modify the backreference designator based on the implementation used. JavaScript users will need to use instead of the previously used . ColdFusion users should use for both find and replace operations. Tip As seen in this example a subexpression may be referred to multiple times simply by referring to the backreference as needed. Let s look at one more example. User information is stored in a database and phone numbers are stored in the format 313-555-1234. However you need to reformat the phone numbers as 313 555-1234. Here is the example 313-555-1234 248-555-9999 810-555-9000 d 3 - d 3 - d 4 1 3- 5 313 555-1234 248 555-9999 810 555-9000 Again two regular expression patterns are used here. The first looks far more complicated than it is so let s walk through it. d 3 - d 3 - d 4 matches a phone number but breaks it into five subexpressions so as to isolate its parts . d 3 matches the first three digits as the first subexpression - matches - as the second subexpression and so on. The end result is that the phone number is broken into five parts each part its own subexpression the area code a hyphen the first three digits of the number another hyphen and then the final four digits. These five parts can be used individually and as needed and so 1 3- 5 simply reformats the number using only three of the subexpressions and ignoring the other two thereby turning 313-555-1234 into 313 555-1234. Tip When manipulating text for reformatting it is often useful to break the text into lots of little subexpressions so as to have greater control over that text. Converting Case Some regex implementations support the use of conversion operations via the metacharacters listed in Table . Table . Case Conversion Metacharacters Metacharacter Description E Terminate L or U conversion l Convert next character to lowercase L Convert all characters up to E to lowercase u Convert next character to uppercase Table . Case Conversion .

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.