regex

U.S. date format regex

This will work with the validation controls in asp dot net.

0?2\/([12]{0,1}\d|0[1-9])/\d{4}|(0?[469]|11)\/([12]{0,1}\d|0[1-9]|30)/\d{4}|(0?[13578]|10|12)\/([12]{0,1}\d|0[1-9]|3[01])/\d{4}

Preparing a text for quotes and more regex goodness on vim

I just finished massaging the text of a book to create a random quote generator.

I started by getting a copy of the book in pdf. From here, I saved a copy to as text. I left it while it was doing its thing since it was taking its sweet time. I expected a monster of a text. However, the text was only about 500K.

I quickly deleted some of the page footer and page header text. Then the fun started.

The sentences were broken at what appeared to be random points. A sentence would start at one line and continue for a few lines on.

Vim regex to gather full sentences over many lines

Okay, here is a little handy regex that I found/created to gather full sentences that are broken over several lines.

/^[A-Z]\_.*?\./

Which translates into:

^ Start the the beginning of a line
[A-Z] Match a capital letter
\_. Match everything including new lines. I got this tip from the link below. Thanks!
* No match or more
? Non greedy! Otherwise the match keeps going until the last line
\. Match the period.

Simple, isn't? :P

http://www.bright-green.com/blog/2004_08_19/multiline_vim_regexps.html

Syndicate content