LEARNING JAVASCRIPT - Trang 265

ing for any word that starts with LIX. What happens next is that the regex goes back

to where it thought it had a match (the L), consumes that L, and moves on, just as

normal. In this instance, it will match NATURE, because the N hadn’t been consumed

as part of LION.
A partial example of this process is shown in

Figure 17-1

.

Figure 17-1. Regex example

Before we move on to discussing the specifics of the regex metalanguage, let’s con‐

sider abstractly the algorithm a regex employs when “consuming” a string:

• Strings are consumed from left to right.
• Once a character has been consumed, it is never revisited.
• If there is no match, the regex advances one character at a time attempting to

find a match.

Input Consumption | 241

Liên Kết Chia Sẽ

** Đây là liên kết chia sẻ bới cộng đồng người dùng, chúng tôi không chịu trách nhiệm gì về nội dung của các thông tin này. Nếu có liên kết nào không phù hợp xin hãy báo cho admin.