余苏明的幻想乡

Chapter 3. Regular Expressions(正则表达式)

Chapter 3. Regular Expressions(正则表达式)

20. Regular Expression Fundamentals(正则表达式基础)

  1. Beginning of line (^ )
  2. End of line ( $)
  3. Single Character (.)
  4. Zero or more Occurrences (*)
  5. One or more Occurrence (\+)
  6. Zero or one Occurrence (\?)
  7. Escaping the Special Character (\)
  8. Character Class ([0-9])

    21. Additional Regular Expressions (扩展正则表达式)

  9. OR Operation (|)
  10. Exactly M Occurrences ({m})
  11. M to N Occurrences ({m,n})
  12. Word Boundary (\b)(单词边界符)
  13. Back References (\n)(反向引用,n为数字)

    22. Sed Substitution Using Regular Expression

    Convert the DOS file format to Unix file format using sed:

    使用sed将DOS下的新行换行符(CR/LF)替换成Unix下的格式
    1
    sed 's/.$//' filename