Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder MrBiggZ's Avatar
    Join Date
    Apr 2005
    Location
    Indianapolis IN
    Posts
    342
    Thanks
    44
    Thanked 2 Times in 2 Posts

    Unhappy Regex across multiple lines

    Greetings!

    I always have trouble with these! Going across multiple lines, grrrrr!

    I concocted this regex:
    Code:
    #.*Type\("(.*?)"\).*Name\("(.*?)"\).*Street\("(.*?)"\).*City\("(.*?)"\).*State\("(.*?)"\).*PostalCode\("(.*?)"\).*AtmType\("(.*?)"\).*LatLng\("(.*?)","(.*?)\)#s
    To search multiples of these type of data (of which I attached a portion of the file I'm using --> pnc01a.txt <-- :

    dmRecord.setDistance("0.15");
    dmRecord.setType("ATM");
    dmRecord.setId("VS076607");
    dmRecord.setName("CVS");

    dmRecord.setStreet("105 E OHIO ST");

    dmRecord.setCity("INDIANAPOLIS");
    dmRecord.setState("IN");
    dmRecord.setPostalCode("46204");

    dmRecord.setItemNumber("5");



    dmRecord.setAtmType("Walk Up");


    dmRecord.setAtmFunctionality("Cash");





    dmRecord.setAtmLanguages("English<BR/>Spanish");





    dmRecord.setHoursOfOperation("24 hours a day");

    dmRecord.setMQLatLng(new MQA.LatLng("39.769859","-86.15601"));
    results.push(dmRecord);

    dmRecord = new DataManagerRecord();
    Regex was made to punish me .. I know it!

    Thanks for your help! Getting better at this .. just this multi line ones throw the monkey wrench into the works! =(
    “No matter how slick the demo is in rehearsal, when you do it in front of a live audience, the probability of a flawless presentation is inversely proportional to the number of people watching, raised to the power of the amount of money involved.” ~ Mark Gibbs

  • #2
    Regular Coder MrBiggZ's Avatar
    Join Date
    Apr 2005
    Location
    Indianapolis IN
    Posts
    342
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Testing even further It works .. but .. when I apply it against the whole file it fizzles!

    PHP Code:
    <?php
    $ptn 
    "#Type."(.*?)".*?Name."(.*?)".*?Street."(.*?)".*?City."(.*?)".*?State."(.*?)".*?PostalCode."(.*?)".*?AtmType."(.*?)".*?LatLng."(.*?)","(.*?)"#s";
    $str " dmRecord.setDistance("0.56"); dmRecord.setType("ATM"); dmRecord.setId("PW2173"); dmRecord.setName("INDIANS BASEBALL STADIUM"); dmRecord.setStreet("501 W MARYLAND"); dmRecord.setCity("INDIANAPOLIS"); dmRecord.setState("IN"); dmRecord.setPostalCode("46255"); dmRecord.setItemNumber("13"); dmRecord.setAtmType("Walk Up"); dmRecord.setAtmFunctionality("Cash"); dmRecord.setAtmAudible("Y"); dmRecord.setAtmLanguages("English<;BR/>;German<;BR/>;Italian<;BR/>;Japanese<;BR/>;Korean<;BR/>;Polish<;BR/>;Portuguese<;BR/>;Spanish"); dmRecord.setPinChagneAvail("Y"); dmRecord.setPersonalizationAvail("Y"); dmRecord.setHoursOfOperation("24 hours a day"); dmRecord.setMQLatLng(new MQA.LatLng("39.765871","-86.168114")); results.push(dmRecord); dmRecord = new DataManagerRecord(); dmRecord.setDistance("0.59"); dmRecord.setType("ATM"); dmRecord.setId("PW2167"); dmRecord.setName("HALL OF CHAMPIONS"); dmRecord.setStreet("700 W WASHINGTON"); dmRecord.setCity("INDIANAPOLIS"); dmRecord.setState("IN"); dmRecord.setPostalCode("46204"); dmRecord.setItemNumber("14"); dmRecord.setAtmType("Walk Up"); dmRecord.setAtmFunctionality("Cash"); dmRecord.setAtmAudible("Y"); dmRecord.setAtmLanguages("English<;BR/>;German<;BR/>;Italian<;BR/>;Japanese<;BR/>;Korean<;BR/>;Polish<;BR/>;Portuguese<;BR/>;Spanish"); dmRecord.setPinChagneAvail("Y"); dmRecord.setPersonalizationAvail("Y"); dmRecord.setHoursOfOperation("24 hours a day"); dmRecord.setMQLatLng(new MQA.LatLng("39.767174","-86.169131")); results.push(dmRecord); dmRecord = new DataManagerRecord(); dmRecord.setDistance("1.2"); dmRecord.setType("ATM"); dmRecord.setId("PW2213"); dmRecord.setName("UNIVERSITY HOSPITAL"); dmRecord.setStreet("1100 W MICHIGAN"); dmRecord.setCity("INDIANAPOLIS"); dmRecord.setState("IN"); dmRecord.setPostalCode("46202"); dmRecord.setItemNumber("15"); dmRecord.setAtmType("Walk Up"); dmRecord.setAtmFunctionality("Cash"); dmRecord.setAtmAudible("Y"); dmRecord.setAtmLanguages("English<;BR/>;German<;BR/>;Italian<;BR/>;Japanese<;BR/>;Korean<;BR/>;Polish<;BR/>;Portuguese<;BR/>;Spanish"); dmRecord.setPinChagneAvail("Y"); dmRecord.setPersonalizationAvail("Y"); dmRecord.setHoursOfOperation("24 hours a day"); dmRecord.setMQLatLng(new MQA.LatLng("39.774636","-86.179131")); results.push(dmRecord); dmRecord = new DataManagerRecord();";
    preg_match_all($ptn$str$matches);
    print_r($matches);
    ?>
    That works. I changed my regex statement a little bit too

    PHP Code:
    $regex '#Type."(.*?)".*?Name."(.*?)".*?Street."(.*?)".*?City."(.*?)".*?State."(.*?)".*?PostalCode."(.*?)".*?AtmType."(.*?)".*?LatLng."(.*?)","(.*?)"#s'
    Frustrating!
    “No matter how slick the demo is in rehearsal, when you do it in front of a live audience, the probability of a flawless presentation is inversely proportional to the number of people watching, raised to the power of the amount of money involved.” ~ Mark Gibbs


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •