Difference between revisions of "Everyday Regular Expressions"

From UCLUG
Jump to: navigation, search
(during the talk)
(A little more descriptions that were given last night.)
 
Line 10: Line 10:
 
*** grep
 
*** grep
 
** metacharacters
 
** metacharacters
*** .
+
*** . ← any character
 
** begin/end of line
 
** begin/end of line
 
*** ^$
 
*** ^$
Line 16: Line 16:
 
*** [dvlshjvkjdlsfhj]
 
*** [dvlshjvkjdlsfhj]
 
*** ranges
 
*** ranges
**** [0-9a=zA-Z]
+
**** [0-9a=zA-Z]  ← notice fat-finger:  a, =, and z not a thru z
 +
**** include dash:  [-0-9] or [a-j-]
 
*** complement
 
*** complement
 
**** [^]
 
**** [^]
 +
**** include caret:  [x^]
 +
**** exclude caret:  [^x^]
 
** quantifiers
 
** quantifiers
*** color colour
+
*** color colour → colou?r
*** helllo hey hello
+
*** helllo hey hello → hel*
 
*** greedy/lazy
 
*** greedy/lazy
 
**** <html>stuff</html>
 
**** <html>stuff</html>
Line 27: Line 30:
 
*** |
 
*** |
 
** subexpressions/grouping
 
** subexpressions/grouping
*** ay/bee/see/dee/ee/eff
+
*** ay/bee/see/dee/ee/eff &rarr;  :s?\(.*\)/\(.*\)?\2/\1?
 
* examples
 
* examples
** ps | grep
+
** ps aux | grep ss[h]
 
** aggressively commented config
 
** aggressively commented config
 +
*** grep ^[^#]  vs  grep -v ^[#]
 
** regex crossword
 
** regex crossword
 +
*** http://regexcrossword.com

Latest revision as of 18:46, 11 December 2013

On December 10, 2013, Jas Eckard gave this talk on Everyday Regular Expressions:

  • what/why
    • wildcards/glob
    • search (replace)
    • "meta-language"
    • BRE, ERE, PCRE
  • components
    • literal characters
      • grep
    • metacharacters
      • . ← any character
    • begin/end of line
      • ^$
    • character classes
      • [dvlshjvkjdlsfhj]
      • ranges
        • [0-9a=zA-Z] ← notice fat-finger: a, =, and z not a thru z
        • include dash: [-0-9] or [a-j-]
      • complement
        • [^]
        • include caret: [x^]
        • exclude caret: [^x^]
    • quantifiers
      • color colour → colou?r
      • helllo hey hello → hel*
      • greedy/lazy
        • <html>stuff</html>
    • alternator
      • |
    • subexpressions/grouping
      • ay/bee/see/dee/ee/eff →  :s?\(.*\)/\(.*\)?\2/\1?
  • examples