I need a regex to match the following and return. Any Ideas? Example: 2011-00002134,6/12/2011 12:36:25 PM Barnes,George,James 555 Main street New Hanover,NY 25555 25 1, Paint 2, Nails 3, Wood Return ID|DATE|TIME|LAST|FIRST|MIDDLE|ADDRESS|CITY STATE|ZIP|AGE|ITEMS 2011-00002134|6/12/2011|12:36:25 PM|Barnes|George|James|555 Main street|New Hanover,NY|25555|25|1, Paint<br>2, Nails<br>3, Wood
i don't have experience with regex. but may be this can help. pass your text to array use file() function file() same with explode divide by new line. ID, DATE and TIME you can get with explode by comma array 0, than explode again by space or substract to get DATE and TIME. LAST, FIRST, MIDDLE get with explode array 1 ADDRESS from array 2 CITY from array 3 ZIP from array 4 AGE from array 5 ITEM get from implode by <br> array 6, 7 and 8