TonyW
TonyW

Reputation: 18885

Java: how to write regex for pattern?

I want to match every row in a CSV file that has the following structure (one row is shown):

9344949,HW488429,10/09/2013 05:00:00 AM,039XX W MONROE ST,0610,BURGLARY,FORCIBLE ENTRY,RESIDENCE,false,false,1122,011,28,26,05,1149955,1899326,2013,10/16/2013 12:39:00 AM,41.87966141386545,-87.72485045045373,"(41.87966141386545, -87.72485045045373)"

I have tried to write this pattern:

Pattern.compile("^([^,]+,){2}\\d{2}/\\d{2}/(\\d{4})([^,]+,){3}([^,]+)");

but it does not work, can anyone please help me with the correction? thanks!

Upvotes: 0

Views: 99

Answers (1)

Nicky Jaidev
Nicky Jaidev

Reputation: 457

I used the tool Expresso to construct some difficult regular expressions. Please have a try.

btw, Can you please give a few more sample rows so that the structure of the row will be better understood.?

Upvotes: 1

Related Questions