Regular expression learning notes

xiaoxiao2021-03-06  75

1. Regular expression is a standard that can be used to find and replace text in a file or character. It has two standards: basic regular expressions (BRE), extended regular expressions (ERE). ERE includes BRE function and other concepts. 2. "|" indicates or operates 3. "." Match any single character 4. "[]" Match any single character contained in any [], such as: [Zhang Wang Li] three, match Zhang San, Wang San, Li "[^]" Will eliminate the characters followed by "^", such as: [^ 0-9] will exclude numbers 6. "?" 0 or 1 front character 7. "*" Match any 0 To any number of characters 8. " " Matches any multiple repetition characters, such as: [Good] people, match "good people", "good people" 9. "{N}" matches n times before {n} Character, such as [is a good person] {2}, match "it is a human" and "good people", do not match "Yes", "is a good person" 10. "{N,}" matches at least n times { The characters before n}, such as: [is a good person] {2,} ah, match "is a good person" and "good people", do not match "Yes" 11. "{n, n}" matches at least n times up to The character before n times {n, n}, such as: [is a good person] {1, 2}, match "Yes" and "good people", do not match "is a good person" 12. "^" From the first Start matching 13. "$" Starts matching from the run 14. "/ <" Match from the start of the word, such as "/ " Match at the end of the word, such as: "/>" is a good person ", does not match" good people "16." / B "match the character or end of the word, such as" / b Good people "match" "Good people", also match "good people" 17. "/ B" match characters in the middle of the word, such as "/ b" Match "is a good person" 18. "/ N" wrap "/ f" page value "/ R "Enter" / t "/ v" Vertical Table "//" Match // "Match / 19."/s" matches any white characters, including spaces, tabs, paging The inquiry. Equivalent to "[/F/n/r/t/v]"20."/s" matches any non-blank characters. Equivalent "[^ / F / N / R / T / V]" 21. "/ W" matches any word character, including letters and underscores. Equivalent to "[A-ZA-Z0-9 _] 22." / W "matches any word characters. Equivalent "[^ a-za-z0-9 _]" 23. "/ D" matches a numeric character, equivalent to [0-9]. Such as "B / DB" matches "B2B", does not match "BBB" and "BB" 24. "/ D" matches a non-digital character, equivalent to [^ 0-9] 25. "/ N" reference N times match results as match conditions.

转载请注明原文地址:https://www.9cbs.com/read-121228.html

New Post(0)