13.07.2015 Views

Download - The Bastards Book of Regular Expressions

Download - The Bastards Book of Regular Expressions

Download - The Bastards Book of Regular Expressions

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Capture, Reuse 84In English We are looking for a 1, followed by a forward-slash, followed by one-or-more numericaldigits, and then another forward-slash and the sequence 2012.Using a capturing group, we wrap the non-year part <strong>of</strong> the date in parentheses. And then we usethe backreference $1 to retrieve the value to use in the replacement:Find (1/\d+)/2012Replace $1/2013In Sublime Text 2, this is what the operation looks like:Sublime Text 2Remember that some variations <strong>of</strong> regex, including the one used in TextWrangler, the backreferenceinvolves a backslash instead <strong>of</strong> a dollar sign:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!