Pre Exam Test Practice (SSC | Banking | IAS | GATE | State Level | CLAT | Railways | Insurance | Teaching Exams | NDA | Defence | IES |State Exam )

Organizational Research By

Surprising Reserch Topic

Question:Regex Refinement


I'm trying to parse addresses out of blocks of text, and have the following expression to do so:

/\d+\s(?:[sewnSEWN]\.?\s)?[\d\w]+\s(?:(?:[\d\w]+\s){0,3})?\w+\.?/

It will currently parse addresses such as:

300 E. Randolph St. Chicago, IL >> Returns 300 E. Randolph St.

5553 Bay Shore Drive >> Returns input

23 Joseph E Lowery Boulevard >> Returns input

513 Martin Luther King Jr Boulevard >> Returns input

This is exactly what I want. I was wondering, as this is the first expression I have ever written, if there was a way to shorten down the expression or refine it a little?

asked Sep 13, 2013 in Java Interview Questions by anonymous
edited Sep 12, 2013
0 votes
18 views



Related Hot Questions



Government Jobs Opening


...