24.2.12

Regex > if

This is a simple one.  I just renewed my love for regular expressions... Sometimes I forget about them and I get lost in a world of if statements.

A Quick refresher : Getting the "FOO" out of FOO_BAR


The regex for this is  

".*(?=_)"

But what if we don't need the _ ?

Just tack on an | !


".*(?=_|$)"

This post is dedicated to SID.

1 comment: