PHP - Php / Expressions / Regex / Help!
Hey all,
Wondering maybe someone can help me out, I am training to be a firefighter (I am not a coder) and am writing a little script for my local volunteer fire brigade to try help em out a little and I am stuck! It doesn't do much but grab the address out of a pager message but I have searched and tried a few ways to get this and now I am tired and just can't get my head around how to do this! Let me explain, Below are 2 pager alert messages and I have a sore head of a time trying to extract the address and job details of the second message into a php string using Expressions/Regex... Here are 2 example messages: Code: [Select] 0571040 15:45:21 30-04-12 @@ALERT F546356345 THEB8 STRUC1 SMELL OF SMOKE AND ALARM OPERATING 900 SOME ROAD SOMESUBURB /CROSSSTREET1 RD //CROSSTREET2 AV M 99 A1 (429085) CTHEB CBOROS PT28 [THEB] 0571040 15:45:21 30-04-12 @@ALERT F546356345 THEB8 STRUC1 SMELL OF SMOKE AND ALARM OPERATING 4 / 900 SOME ROAD SOMESUBURB /CROSSSTREET1 RD //CROSSTREET2 AV M 99 A1 (429085) CTHEB CBOROS PT28 [THEB] You will note the second address has 4 / 900 at the start or it could say Unit 4 / 900... and this is where my issue starts! The addresses can come in the 2 different formats, I have first one sorted with the code below but this address with no 4 / 900 some road just has me and my code below stumped. The extra / is just to complex a thing for me and my brain to handle! lol Please Help! As you can see I use the first slash as the first cross street but in the second case above the first / is now a part of the address... Below is what I have so far: Code: [Select] function get_string_between2($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } $fullstring = "$rawPage"; if ( strpos($fullstring, ' STRUC1 ')!== false ) { $parsed = get_string_between2($fullstring, "STRUC1", "/"); } $input = "$parsed"; preg_match('/([^0-9]+)(.*)/', $input, $matches); $jobdet = "$matches[1]"; $jobadd = "$matches[2]"; Now this works fine for the top message and I get this as the result: $jobdet = SMELL OF SMOKE AND ALARM OPERATING $jobadd = 900 SOME ROAD SOMESUBURB $firstcrossstreet = /CROSSSTREET1 RD $secondcrossstreet = //CROSSSTREET2 AV For the second message it's all wrong with this the result: $jobdet = SMELL OF SMOKE AND ALARM OPERATING $jobadd = 4 $firstcrossstreet = / 900 SOME ROAD SOMESUBURB /CROSSSTREET1 RD $secondcrossstreet = //CROSSSTREET2 AV I know it's the / causing it but how can I make the code handle either case? Any help would be greatly appreciated! Thanks! Similar Tutorialsi need to split words and add to a array from filter input. i can split words with [ ] (Space character). But also i need to not split "word1 word2" with space character. for example: Filter input "word1 word2" word3 word4 my array will need to be like this after split arr[0] = word1 word2 arr[1] = word3 arr[2] = word4 can some one help me about this? By the way im sorry for my poor english Thanx This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=341968.0 Okay, I have a problem. I need to display multilple output of a file with a similar file name I.E. file1: 6002010.pdf file2: 6002010.mmddyyyy.pdf Now the first part of the file stays the same, but there is a time stamp on modified versions of the file. But in my output I need to display all the files with the 6002010. Could I use a wildcard such as 6002010* to get all the files to output on the screen? Or do I need to use a regular expression? This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=351100.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=315565.0 I have a payment form that submits its results to Authorize.net. It works on my laptop without an SSL certificate using an Authorize.net test account. But when I transfer this one file over to my GoDaddy account - which has cURL enabled and an SSL certificate - the page crashes when you submit the form results. (Actually you just get a blank page except for echo statements I added?!) If I take out my "Form Validation" block - which uses Regular Expressions - then the form runs on the server?! Someone said it might be that "cURL must have SSL enabled in the build", but that isn't the issue, because I can send data to an HTTPS connection and receive a response back?! Here is a streamlined version of my code... Code: [Select] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link type="text/css" rel="stylesheet" href=".css"> <style type="text/css" > someStyleHere{ font-weight: bold; } </style> </head> <body> <?php // Check Form. echo '*** Checking for Submitted Form ***<br />'; if (isset($_POST['submitted'])){ // Handle Form. echo '*** Form was Submitted ***<br />'; echo '*** Handling Form ***<br />'; // Trim all incoming data. $trimmed = array_map('trim', $_POST); // CHECK BILLING INFORMATION. echo '*** Check for Form Errors ***<br />'; // Check First Name. if (!empty($_POST['firstName'])){ if (preg_match('/^[A-Z \'.-]{2,20}$/i', $_POST['firstName'])){ $firstName = $_POST['firstName']; }else{ $errors['firstName'] = 'Must be 2-20 characters (A-Z \' . -)'; } }else{ $errors['firstName'] = 'Please enter your First Name.'; } // Determine if any errors. if (empty($errors)){ // PROCESS PAYMENT. echo '*** Processing Form ***<br />'; $post_url = "https://test.authorize.net/gateway/transact.dll"; // Output the Response Array to the screen as an HTML Numbered List. echo "<OL>\n"; foreach($response_array as $value){ echo "<LI>" . $value . " </LI>\n"; } echo "</OL>\n"; // Printe Response Code. switch($response_array[0]){ case "1": echo "Response Code: Approved"; break; case "2": echo "Response Code: Declined"; break; } // Do not re-display Payment Form!!! exit(); // ********************************************************************* }// End of PROCESS PAYMENT. }// End of HANDLE FORM. ?> <!-- HTML PAYMENT FORM --> <form id="payment" action="" method="post"> <fieldset> <legend>Billing Details</legend> <ol> <!-- First Name --> <li> <label for="firstName">First Name:</label> <input id="firstName" name="firstName" class="text" type="text" maxlength="20" value="<?php echo $firstName; ?>" /> <?php if (!empty($errors['firstName'])){ echo '<span class="error">' . $errors['firstName'] . '</span>'; } ?> </li> </ol> </fieldset> <!-- Submit Form --> <fieldset id="submit"> <input name="submit" type="submit" value="Place Order" /> <input name="submitted" type="hidden" value="true" /> </fieldset> </form> </body> </html> With my Regular Expressions in, I get this output after submitting the form... Quote *** Checking for Submitted Form *** *** Form was Submitted *** *** Handling Form *** With NO Regular Expressions in, I get this output after submitting the form... Quote *** Checking for Submitted Form *** *** Form was Submitted *** *** Handling Form *** *** Check for Form Errors *** *** Processing Form *** post-string = x_login= and so on... Response Code: Approved (Which means the code is working...) I am at wit's end with this problem... Thanks, Debbie This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=334128.0 I have been playing with reg ex patterns for the last couple of hours. I realized I have been coding in security a hole. But for the life of me I don't know the answer. In preg match it will return a 1 true. So the code below is saying if you find anything that is not one of these values the condition is true. Meaning anything but a-zA-Z true is this correct? How do I make it so if you find anything but a-zA-Z return false? Code: [Select] if ( preg_match('/[a-zA-Z]/', $_GET['contact'] )== 1) hello. There is a project i take and i can't handle it. the project goes like this. I get site code by file_get_contents function into variable. Than I need to find the iframe and delete it from the variable. for example the code i getting from the file_get_contents is looking like this : <html> <body> This is site ! <iframe> LINK </iframe> </body> </html> now , simply i can track the iframe and delete it just like this. $str = preg_replace('/\<{1}iframe[a-zA-Z0-9=+\/\'.]/' , '' , $str);/** this is not the right regex i use , the full one contain all chars except < .**/ So I can find the < symbol and than delete all iframe section. the problem come when I get code like this. <html> <body> This is site ! <iframe> <iframe>LINK </iframe></iframe> </body> </html> So , from here I can't handle it since I don't know where the iframe ends since there is many < symbols. Second question is maybe with regex i can handle something like this? looking for start , than get everything between and stop at the end. $reg ='/^\<{1}iframe .+\<{1}iframe\>{1}/i'; Is that possible to do something like this with regex? any suggestions how to make it done? hope i was clear. thanks , Mor. Well I'm stuck... So I'm trying to make the php print out the text between Code: [Select] title="Text here" <?php function Betweens($string) { $pattern = '/title="(.*?)"/'; //It fails here preg_match($pattern, $string, $matches); return $matches[1]; } $str = '<iu pageid="2022" ns="0" title="Test" />'; $p = Betweens($str); echo $p; ?> So yea I really suck at regex's.. Edit: God damn it, now I see I've posted in wrong sector -.- I have a CSV file which has more than 50k records and i want to convert this using regex I want to make it so if($message=="" . $cmdPrefx . "deleteall: "){ echo substr(strrchr($message, ' '), 1); Doesn't use =="something" How can I make it so anything after deleteall: is a wildcard? I'm assuming using regex, but have no idea how Hey Guys,
I'm receiving an api request back that looks like:
[{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174222182518,"lsrc":80972326202,"ltgt":31581262572,"luuu":"groups.google.com/group/comp.infosystems.www.users/msg/9a210e5f72278328","pda":100,"ueid":355370,"uid":358079,"ulc":1394603890,"umrp":7.348021108330069,"umrr":4.2306065019844527e-07,"upa":95.04277845195264,"us":200,"ut":"HTTP cookie - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/HTTP_cookie"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174457993090,"lsrc":80972326202,"ltgt":31622557610,"luuu":"support.google.com/chrome/answer/95582?hl=en","pda":100,"ueid":355370,"uid":358079,"ulc":1394603890,"umrp":7.348021108330069,"umrr":4.2306065019844527e-07,"upa":95.04277845195264,"us":200,"ut":"HTTP cookie - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/HTTP_cookie"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174457997214,"lsrc":80972326202,"ltgt":31622557668,"luuu":"support.google.com/chrome/answer/95626?hl=en","pda":100,"ueid":355370,"uid":358079,"ulc":1394603890,"umrp":7.348021108330069,"umrr":4.2306065019844527e-07,"upa":95.04277845195264,"us":200,"ut":"HTTP cookie - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/HTTP_cookie"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174704422109,"lsrc":80972326202,"ltgt":31675615115,"luuu":"www.google.com/support/chrome/bin/answer.py?hl=en&answer=95582","pda":100,"ueid":355370,"uid":358079,"ulc":1394603890,"umrp":7.348021108330069,"umrr":4.2306065019844527e-07,"upa":95.04277845195264,"us":200,"ut":"HTTP cookie - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/HTTP_cookie"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174704422260,"lsrc":80972326202,"ltgt":31675615123,"luuu":"www.google.com/support/chrome/bin/answer.py?hl=en&answer=95626","pda":100,"ueid":355370,"uid":358079,"ulc":1394603890,"umrp":7.348021108330069,"umrr":4.2306065019844527e-07,"upa":95.04277845195264,"us":200,"ut":"HTTP cookie - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/HTTP_cookie"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051896270,"lsrc":80975346908,"ltgt":31567049373,"luuu":"books.google.com/?id=0IZboamhb5EC&lpg=PA731","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051900386,"lsrc":80975346908,"ltgt":31567051168,"luuu":"books.google.com/?id=58KxPNa0hF4C&lpg=PA463","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051902110,"lsrc":80975346908,"ltgt":31567051879,"luuu":"books.google.com/?id=6xiYiybkE8kC&vq=core","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051902955,"lsrc":80975346908,"ltgt":31567052243,"luuu":"books.google.com/?id=7veohk0fkLYC&lpg=PA88","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051904343,"lsrc":80975346908,"ltgt":31567052883,"luuu":"books.google.com/?id=9iQYSQ9y60MC&lpg=PA49","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051905960,"lsrc":80975346908,"ltgt":31567053635,"luuu":"books.google.com/?id=BgZyXNIrvB4C&pg=PT12","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051911261,"lsrc":80975346908,"ltgt":31567055934,"luuu":"books.google.com/?id=Ho_RmgOnwgwC&lpg=PA8","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051913146,"lsrc":80975346908,"ltgt":31567056717,"luuu":"books.google.com/?id=JttyjBoyb3AC&lpg=PA12","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051920509,"lsrc":80975346908,"ltgt":31567059840,"luuu":"books.google.com/?id=SF7U27JsLC4C&dq=iraq+invasion+removes+hussein","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051921673,"lsrc":80975346908,"ltgt":31567060362,"luuu":"books.google.com/?id=T_0TrXXiDbUC&dq=slavery+%22American+Civil+War%22","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051922547,"lsrc":80975346908,"ltgt":31567060715,"luuu":"books.google.com/?id=UYpVAAAAYAAJ","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051925466,"lsrc":80975346908,"ltgt":31567061980,"luuu":"books.google.com/?id=Y1dOLQN9hvwC&dq=SEALs+kill+Osama+bin+Laden","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051936195,"lsrc":80975346908,"ltgt":31567066473,"luuu":"books.google.com/?id=jLy-NKnQitIC&pg=PA45&dq=uk+us+special+relationship","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051937261,"lsrc":80975346908,"ltgt":31567066890,"luuu":"books.google.com/?id=ka6LxulZaEwC&vq=annexation&dq=territorial+expansion+United+States+%22manifest+destiny%22","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051943179,"lsrc":80975346908,"ltgt":31567069364,"luuu":"books.google.com/?id=r71u_AgE7iYC&lpg=PA142","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051949934,"lsrc":80975346908,"ltgt":31567072219,"luuu":"books.google.com/?id=yd4GqkP5XYgC&lpg=PA229","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051950951,"lsrc":80975346908,"ltgt":31567072673,"luuu":"books.google.com/?id=zq4rsWNrYo4C&q=Reaganomics&dq=Reaganomics","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174052414947,"lsrc":80975346908,"ltgt":31567405066,"luuu":"books.google.com/books/about/A_History_of_the_American_People.html?id=RXSVQjz1_tMC","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174052676940,"lsrc":80975346908,"ltgt":31567608329,"luuu":"books.google.com/books/about/An_Empire_of_Wealth.html?id=rmsUs_KDgHAC","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174054227159,"lsrc":80975346908,"ltgt":31568894639,"luuu":"books.google.com/books/about/History_of_the_American_Economy_With_Acc.html?id=lyhI1q_E4G0C","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"}]I'm trying to retrieve all the backlinks located in these parts: "uu":"en.wikipedia.org/wiki/HTTP_cookie" "uu":"en.wikipedia.org/wiki/United_States" etc I tried this regex: $regex = returnSeoMozLinks("google.com"); $pattern = '""uu"":""(.*?)""'; $success = preg_match($pattern, $regex, $match); if ($success) { echo "Match: ".$match[0]."<br />"; }But it doesn't seem to work, i can do it in vb net but i am rusty with php lol any help would be appreciated guys! cheers Graham Ok, my first post here (earlier today) was a huge help, so here's a second... I have the following PHP code: $name = $row['NAME']; $nameTrimmed = $name; if ((strlen($nameTrimmed) > 20) && (strlen($nameTrimmed) > 1)) { $whitespaceposition2 = strrpos($nameTrimmed," ",5); $nameTrimmed = substr($nameTrimmed, 0, $whitespaceposition2); echo $nameTrimmed . "..."; } if ((strlen($name) <= 20) && (strlen($name) > 0)) { echo $name; } This is working as expected. However, many of the "name" fields in the DB contain &trade; and &reg; strings, which inflate the count of each product title. Since I'm using the strrpos to limit the length of the longer product names (due to limited space in the layout), I would like to show as many full titles as possible. Many are being cut prematurely short due to the extra characters from the symbols. Do I need to run all this through a regex filter before I count it? If so, can anyone share an example of code I could try? Regex has never been my weak point, let alone my strong point. Or is there something else I haven't thought of? Any help is greatly appreciated! hey guys im after the pattern to replace , and & symbols please?...any help would be great
thank you
I am trying to use preg_match_all to find some information on a webpage. Here is what I am currently using <?php $homepage = "http://www.example.com"; $page_contents1 = file_get_contents($homepage); $names1 = preg_match_all('/<span class="video_date">(.*)</span> - <a class="b" href="/(.*)/">(.*)</a><br/>\/', $page_contents1, $matches1); echo implode(", ", $matches1[1]); ?> I am trying to match this piece of html: <span class="video_date">Oct 21</span> - <a class="b" href="/meanwhilezealand/"> Meanwhile in New Zealand...</a><br/> Thanks for looking! This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=308051.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=344155.0 If I want to negate this... Code: [Select] if (preg_match()) Would this work... Quote if (!preg_match()) Debbie |