Regular Expression Exercise:
In groups, come up with your best regular expression for

1) an if statement in Java (allow for backreferences to the condition and body)

Example: if (x==0) {
	x++;
}
$1 should contain x==0
$2 should contain x++;

Based on Bori's and Kirk's answer
^if\s*\((.+)\)\s*\{\s*(.*)\s*\}$
         $1            $2
Note that the condition cannot be empty, body can be
Using \s* means optional newlines
Use ^ and $ for beginning and end (e.g. don't match an else if)

2) emoticons - e.g. ;), :P, :-(

Sample answers:
simple happy face - [:=]-?\)
happy and sad - [:=]-?[()]
more complex - (>?[:=;]-?)|[xX][()\]\[DPp]
(>?[:=;]-?)               |[xX]                  [()\]\[DPp]
top half of face        OR x and X (e.g. xD)     mouths :(, :], :D, :p, etc.     
optional angry face >? e.g. >:(
eyes [:=;]
optional nose -?

Based on Julia's answer:
((:|;)(-?)([pPD()\[\]]))\s
$1 will return the smiley face itself
Use \s instead of $ at the end ($ means smiley must be at end of line)

Jake's answer:
/([:;][-~]?[()DpP$*|])|([()D$*|][-~]?[;:])|
([T@$*\^oO][_][T@$*\^oO])/
First line allows for :) or (:
Second line allows for o_O
This is where building them up in pieces would be really helpful 
since we can reuse them (e.g. see slide 83)

