Regex Help

Discussion in 'PHP' started by yelbom, Dec 27, 2012.

  1. #1
    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
     
    yelbom, Dec 27, 2012 IP
  2. ogah

    ogah Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #2
    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 &lt;br&gt; array 6, 7 and 8
     
    ogah, Dec 27, 2012 IP
  3. yelbom

    yelbom Greenhorn

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    I cant use your method cause the data isnt always in same format.

     
    yelbom, Dec 31, 2012 IP