PageRenderTime 41ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/regexp.yml

https://github.com/felixgao/chitsheet
YAML | 32 lines | 26 code | 6 blank | 0 comment | 0 complexity | 5170a108ec9c77b4730ed09af0ad5a36 MD5 | raw file
  1. ---
  2. regexp: |-
  3. A regexp's form is written /pattern/modifiers where "pattern" is the regular expression itself, and "modifiers" are a series of characters indicating various options.
  4. (see an alternate/more complete cheat-sheet with 'cheat regex')
  5. /i makes match case insensitive.
  6. /m makes the dot match newlines.
  7. /o causes any #{...} substitutions in a particular regex literal to be performed just once, the first time it is evaluated. Otherwise, the substitutions will be performed every time the literal generates a Regexp object.
  8. [] range specification (e.g., [a-z] means a letter in the range a to z)
  9. \w letter or digit; same as [0-9A-Za-z]
  10. \W neither letter or digit
  11. \s space character; same as [ \t\n\r\f]
  12. \S non-space character
  13. \d digit character; same as [0-9]
  14. \D non-digit character
  15. \b backspace (0x08) (only if in a range specification)
  16. \b word boundary (if not in a range specification)
  17. \B non-word boundary
  18. * zero or more repetitions of the preceding
  19. + one or more repetitions of the preceding
  20. {m,n} at least m and at most n repetitions of the preceding
  21. ? at most one repetition of the preceding; same as {0,1}
  22. | either preceding or next expression may match
  23. () grouping
  24. print "success" if subject =~ /regex/
  25. result = subject.gsub(/before/, "after")
  26. myarray = mystring.scan(/delimiter/)