tailieunhanh - Oreilly learning the vi Editor phần 6

Trừ khi bạn đã quen thuộc với biểu thức thông thường Đã có, các cuộc thảo luận của các ký tự đặc biệt phức tạp trông forbiddingly Có lẽ trên. Một vài ví dụ hơn Những điều nên làm cho rõ ràng hơn. Trong các ví dụ đó làm theo, một hình vuông () được sử dụng để đánh dấu một không gian trống, nó không phải là một nhân vật đặc biệt. | Chapter 6 Pattern-matching Examples I PREVIOUS Chapter 6 Global Replacement NEXT Pattern-matching Examples Unless you are already familiar with regular expressions the discussion of special characters above probably looks forbiddingly complex. A few more examples should make things clearer. In the examples that follow a square is used to mark a blank space it is not a special character. Let s work through how you might use some special characters in a replacement. Suppose that you have a long file and that you want to substitute the word child with the word children throughout that file. You first save the edited buffer with w then try the global replacement s child children g When you continue editing you notice occurrences of words such as childrenish. You have unintentionally matched the word childish. Returning to the last saved buffer with e you now try s childn childrenD g Note that there is a space after child. But this command misses the occurrences child. child child and so on. After some thought you remember that brackets allow you to specify one character from among a list so you come upon the solution s child D . children EZI . g This searches for child followed by either a space indicated by or any one of the punctuation characters . . You expect to replace this with children followed by the corresponding space or punctuation mark but you ve ended up with a bunch of punctuation marks after every occurrence of children. You need to save the space and punctuation marks inside a and . Then you can replay them with a 1. Here s the next attempt s child D . children 1 g When the search matches a character inside the and the 1 on the right-hand side restores the same character. The syntax may seem awfully complicated but this command sequence can save you a lot of work Any time you spend learning regular expression syntax will be repaid a thousandfold The command is still not perfect though. You ve noticed that occurrences of Fairchild have been .

TỪ KHÓA LIÊN QUAN
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.