Jump to content

Search the Community

Showing results for tags 'preg_match'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 24 results

  1. this is my code $re = '/[^\W][a-zA-Z\d.-]{3,20}/'; if(!preg_match_all($re, $username)){ do something }else{ do somthing else } $username is a $_POST['username']; when i submit a 3 letter word it works but when i use symbols like $ and ! and etc it still goes through, im trying to get a regex where the username is 4-20 characters long and only the alphabet and numbers and dots and dash but dots and dashs cant be next to each other thx
  2. I am trying to use preg_match to check whether a membership number has been entered in the form 'A123456'. I have found a site on the web that shows the types of string syntax that can be used to check a string, so I have come up with the following: preg_match ('/P.P/ \d{6}', $trimmed['BMFA_No']) However when run I get the following error: An error occurred in script D:\wamp\www\MFC1066\Reg1.php on line 19: preg_match(): Unknown modifier '\' Obviously I have the syntax wrong, but as I have never used this command before I am unsure where this is wrong. I am sure that someone out there is much more experienced that me and can solve this easily.
  3. Hi guys, I am trying to handle a html form that users are copying and pasting to a form on my website that contains their schedule for a particular day. Generally the format is the same so I am trying to handle the data with a preg_match however sometimes white spaces or blank fields do not upload to my mysql db correctly. An example of the html code from the html table is below: <tr class="row-border-top marked-row "> <td>13 Dec 15, Sun</td> // always the same format <td>OFF(Z)</td> // can vary to contain [a-zA-Z], numericals, brackets, forward slash and possible whitespaces (no guarantee of how many if they are present) <td>DOZ</td> // only three letter characters, empty, or white spaces <td>: </td> // generally contains a time in format hh:mm however could be a) blank, b) only contain ':', c) contain just blank spaces <td>: </td> // generally contains a time in format hh:mm however could be a) blank, b) only contain ':', c) contain just blank spaces <td></td> // only three letter characters or blank </tr> <tr class="row-border-top marked-row "> <td>12 Dec 15, Sat</td> // another row example <td>B/HOL(Z)</td> <td>DOZ</td> <td>: </td> <td>: </td> <td></td> </tr> <tr class="marked-row "> // another row example <td>8 Dec 15, Tue</td> <td>3329</td> <td>RZS</td> <td>17:20</td> <td>21:55</td> <td>DOZ</td> </tr> so far I have the code as follows: else { if (preg_match("#([^,]+), \w{3}[\s]+(.+?)[\s]+(\w{3})[\s]+(\d\d:\d\d) Z[\s]+(\d\d:\d\d) Z[\s]+(.*)#", $line, $match)) { $code = $_SESSION['Code']; $date = date('d/m/Y', strtotime($match[1])); $sectordate = date('Y/m/d', strtotime($match[1])); $duty = $match[2]; $dep = $match[3]; $begin = $match[4]; $end = $match[5]; $arr = $match[6]; $output .= "<tr><td>{$date}</td><td>{$duty}</td><td>{$dep}</td><td>{$begin}</td><td>{$end}</td><td>{$arr}</td></tr>\n"; $addedon = date('Y-m-d H:i:s'); $today = date('Y-m-d'); $sql= "INSERT INTO table (RostersID,Code,Ffname,Fuid,SectorDate,Duty,Dep,BeginTime,EndTime,Arr,AddedOn,Random) VALUES('','$code','{$_SESSION['FULLNAME']}','{$_SESSION['FBID']}','$sectordate','$duty','$dep','$begin','$end','$arr','$addedon','$random')"; $result = mysqli_query($cxn,$sql) or die ("Can not upload the new roster!"); $sql = "SELECT * FROM table WHERE Code = '$code' AND Random !='$random'"; $result = mysqli_query($cxn,$sql) or die ("Can not find the old roster duties to delete then update with the new."); while($row=mysqli_fetch_assoc($result)) { $sql1 = "DELETE FROM table WHERE SectorDate='$sectordate' AND Code='$code' AND Random !='$random'"; $result1 = mysqli_query($cxn,$sql1) or die ("Can't execute!"); } } }
  4. Hi every one i have php script its work on my localhost and my dedicated server php version 5.3 but it's not work on my ipage hosting please help me this the code clean.php <?php /** * Replace accented characters with non accented * * @param $str * @return mixed * @link http://myshadowself.com/coding/php-function-to-convert-accented-characters-to-their-non-accented-equivalant/ */ function removeAccents($str) { $a = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'Ā', 'ā', 'Ă', 'ă', 'Ą', 'ą', 'Ć', 'ć', 'Ĉ', 'ĉ', 'Ċ', 'ċ', 'Č', 'č', 'Ď', 'ď', 'Đ', 'đ', 'Ē', 'ē', 'Ĕ', 'ĕ', 'Ė', 'ė', 'Ę', 'ę', 'Ě', 'ě', 'Ĝ', 'ĝ', 'Ğ', 'ğ', 'Ġ', 'ġ', 'Ģ', 'ģ', 'Ĥ', 'ĥ', 'Ħ', 'ħ', 'Ĩ', 'ĩ', 'Ī', 'ī', 'Ĭ', 'ĭ', 'Į', 'į', 'İ', 'ı', 'IJ', 'ij', 'Ĵ', 'ĵ', 'Ķ', 'ķ', 'Ĺ', 'ĺ', 'Ļ', 'ļ', 'Ľ', 'ľ', 'Ŀ', 'ŀ', 'Ł', 'ł', 'Ń', 'ń', 'Ņ', 'ņ', 'Ň', 'ň', 'ʼn', 'Ō', 'ō', 'Ŏ', 'ŏ', 'Ő', 'ő', 'Œ', 'œ', 'Ŕ', 'ŕ', 'Ŗ', 'ŗ', 'Ř', 'ř', 'Ś', 'ś', 'Ŝ', 'ŝ', 'Ş', 'ş', 'Š', 'š', 'Ţ', 'ţ', 'Ť', 'ť', 'Ŧ', 'ŧ', 'Ũ', 'ũ', 'Ū', 'ū', 'Ŭ', 'ŭ', 'Ů', 'ů', 'Ű', 'ű', 'Ų', 'ų', 'Ŵ', 'ŵ', 'Ŷ', 'ŷ', 'Ÿ', 'Ź', 'ź', 'Ż', 'ż', 'Ž', 'ž', 'ſ', 'ƒ', 'Ơ', 'ơ', 'Ư', 'ư', 'Ǎ', 'ǎ', 'Ǐ', 'ǐ', 'Ǒ', 'ǒ', 'Ǔ', 'ǔ', 'Ǖ', 'ǖ', 'Ǘ', 'ǘ', 'Ǚ', 'ǚ', 'Ǜ', 'ǜ', 'Ǻ', 'ǻ', 'Ǽ', 'ǽ', 'Ǿ', 'ǿ', 'Ά', 'ά', 'Έ', 'έ', 'Ό', 'ό', 'Ώ', 'ώ', 'Ί', 'ί', 'ϊ', 'ΐ', 'Ύ', 'ύ', 'ϋ', 'ΰ', 'Ή', 'ή'); $b = array('A', 'A', 'A', 'A', 'A', 'A', 'AE', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 's', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'IJ', 'ij', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'l', 'l', 'N', 'n', 'N', 'n', 'N', 'n', 'n', 'O', 'o', 'O', 'o', 'O', 'o', 'OE', 'oe', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 's', 'f', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'A', 'a', 'AE', 'ae', 'O', 'o', 'Α', 'α', 'Ε', 'ε', 'Ο', 'ο', 'Ω', 'ω', 'Ι', 'ι', 'ι', 'ι', 'Υ', 'υ', 'υ', 'υ', 'Η', 'η'); return str_replace($a, $b, $str); } ?> usage.php <?php include "clean.php"; $string = 'عقب محاولة انتحارها من أجل صورة سيلفي مريم الشناوي تعود للحياة من جديد بفيديو سيلفي'; $urlresult = removeAccents($string); if (!preg_match("~^[a-zA-Z0-9٠-٩\-+,()/'\s\p{Arabic}]{1,300}$~", $urlresult)) { echo "found"; } else { echo $string; } ?>
  5. When I read HTML source of below link http://www.dresslink.com/women-candy-color-handbag-leather-cross-body-shoulder-bag-bucket-bag-p-10908.html I can find below data about the product: <script type="text/javascript"> item.stock['ss42356']=[]; DL.item.stock['ss42356']['qty']=56; DL.item.stock['ss42356']['sku']='SV000837_B'; DL.item.stock['ss42356']['inexistence']=0; DL.item.stock['ss42356']['down_shelf']=0; DL.item.stock['ss42356']['procurement_cycle']='8'; DL.item.stock['ss42356']['paid_set']=[]; DL.item.stock['ss42356']['paid_set'].push(35630); DL.item.color_image['35630']='of7ea7'; DL.item.stock['ss42357']=[]; DL.item.stock['ss42357']['qty']=29; DL.item.stock['ss42357']['sku']='SV000837_G'; DL.item.stock['ss42357']['inexistence']=0; DL.item.stock['ss42357']['down_shelf']=0; DL.item.stock['ss42357']['procurement_cycle']='6'; DL.item.stock['ss42357']['paid_set']=[]; DL.item.stock['ss42357']['paid_set'].push(35631); DL.item.color_image['35631']='of710e'; DL.item.stock['ss42358']=[]; DL.item.stock['ss42358']['qty']=14; DL.item.stock['ss42358']['sku']='SV000837_BR'; DL.item.stock['ss42358']['inexistence']=0; DL.item.stock['ss42358']['down_shelf']=0; DL.item.stock['ss42358']['procurement_cycle']='17'; DL.item.stock['ss42358']['paid_set']=[]; DL.item.stock['ss42358']['paid_set'].push(35632); DL.item.color_image['35632']='of77c1'; DL.item.stock['ss42359']=[]; DL.item.stock['ss42359']['qty']=36; DL.item.stock['ss42359']['sku']='SV000837_O'; DL.item.stock['ss42359']['inexistence']=0; DL.item.stock['ss42359']['down_shelf']=0; DL.item.stock['ss42359']['procurement_cycle']='7'; DL.item.stock['ss42359']['paid_set']=[]; DL.item.stock['ss42359']['paid_set'].push(35633); DL.item.color_image['35633']='of7136'; </script> I need to know the quantity for each SKU, so I need to produce a simple array containing each SKU name and it's quantity like below $a = array( 'SV000837_B' => '56', 'SV000837_G' => '29', 'SV000837_BR' => '14', 'SV000837_O' => '36', ); Please help me write a PHP code using regex and any other method to provide above array.
  6. I have a group of letter that consists letters like $words= 'estroaroint'; that can be arranged to be some words in my list $file = 'dictionary.txt' Here my expected result that on my words list: STORE REST TRAIN RESTORATION ...etc I searched on google and found like : $contents = file_get_contents($file); $pattern = preg_quote($words, '/'); $pattern = "/^.*$pattern.*\$/m"; if(preg_match_all($pattern, $contents, $matches)){ echo "Found matches:\n"; echo implode("\n", $matches[0]); echo strlen($matches); } else{ echo "No matches found"; } But that's not like as my expectation Thanks in advance Warm Regard
  7. Hey guys, I am stuck on this preg_match if statement. I want to allow ' and " in the variable string but for some reason it keeps reporting invalid characters when I add ' or " to the string. Any help would be appreciated as I have tried tons of combinations after searching google. Thanks! if(preg_match("/[^a-zA-Z0-9\-\_\,\!\?\.\'\"\ \/]+/i",$_POST['article_title'])) { $err[]='<p class="error" style="color: #ed1c24;">Your Title contains invalid characters!</p>'; }
  8. This is my preg_match code: preg_match("/(\d+)|(T)|(A)/", $link, $matches, PREG_OFFSET_CAPTURE, ($off-30) It works and matches the number I want, except it only returns the first character in the $matches array. For instance, if the number it finds is 10, it only returns 1. Now I understand that is what preg_match does, but how would I make that regex ungreedy? I tried adding a *, but it just made an error, and preg match all would keep searching for strings after the first one. All I want is for the first number, regardless of the length of it, to be returned in full. Thanks for any help.
  9. Hi, I don't know much about php. Recently my host updated php version to 5.4 and i function eregi() is deprecated errors, so after some googling, replaced it with preg_match but i am stuck with errors Code: preg_match("^ and", "", $mid_str) Error: Warning: preg_match(): No ending delimiter '^' found Tried the following method but not working preg_match("/^ and/", "", $mid_str) Can you guys help me with correct code? Thanks for looking.
  10. Hi, I am fairly new to PHP, I am tryin to put a code together that would see my incoming CLI as 44 and remove the 44 from it and add a 0 to it. I have managed to do this so far, now I am stuck, as any number thats not matching the length (10 digits ) or is not starting with 44 is also not forwarded to my database for query. $input = ($cid); if(preg_match('/^(44|0)(\d{10})$/',$input,$matches)){ $phone = '0'.$matches[2]; }else die("Invalid Phone Number") ; What I would like is that any number starting with 441234567890 to become 01234567890, but should not involve 10 digits criteria. Any help would be appreciated.
  11. I have problem creating patern with preg_match_all and add it to array, its involved json data, Ch0cu3r helped me alot with my previous question http://forums.phpfreaks.com/topic/285059-preg-match-all-problem/, maybe he is still around? VI.data.aurora.idx = {140108: {act: 3, sun: ['s0','16:00','11:08','17:12','09:56'], moon: ['7','t3','03:51','']}, 140109: {act: 2, sun: ['s0','16:02','11:06','17:14','09:55'], moon: ['8','t3','05:12','']}, 140110: {act: 2, sun: ['s0','16:05','11:04','17:16','09:54'], moon: ['9','t3','06:28','']}, 140111: {act: 3, sun: ['s0','16:08','11:02','17:18','09:52'], moon: ['10','t3','07:35','']}, 140112: {act: 2, sun: ['s0','16:11','11:00','17:20','09:51'], moon: ['11','t3','08:30','']}, 140113: {act: 2, sun: ['s0','16:14','10:57','17:23','09:49'], moon: ['12','t3','09:11','']}, 140114: {act: 2, sun: ['s0','16:17','10:55','17:25','09:48'], moon: ['13','t3','09:41','']}, 140115: {act: 2, sun: ['s0','16:20','10:53','17:27','09:46'], moon: ['14','t4','16:33','10:03']}, 140116: {act: 2, sun: ['s0','16:23','10:50','17:30','09:44'], moon: ['15','t4','17:46','10:18']}, 140117: {act: 2, sun: ['s0','16:26','10:48','17:32','09:42'], moon: ['16','t4','19:03','10:30']}}
  12. I have the following string : 't':new Date(2014,1-1,3,9,35,38),'a':'3.57289','lat':'12,123','lon':'-12,123','dep':'1,1','s':'1,0','q':'90,02','dL':'4,3','dD':'VSV','dR':'PlaceName' t=date and time a=? lat=latitude lon=longitude dep=depth s=magnitude q=quality dL=? dD=direction dR=PlaceName I am trying to get the data into array with preg_match_all Can anyone help me out?
  13. Hi there, I'm struggling a bit with this. This works fine: line 99: preg_match('^\s', $xmlElem) However, I shouldn't be writing the pattern there directly, because the pattern is in a tab-separated file. If I get it with fgetcsv and put it in another variable $pattern = $data[0]; echo $pattern; // outputs ^\s and then use that variable in the above match line 99: preg_match('/'. $pattern .'/', $xmlElem) then I get an error like: and there's no match. Could anyone help me out? Thank you so much! Cheers, Manuel
  14. Hi, I'm trying to get some search results from google by using cURL and preg_match. <?php $curl = curl_init(); curl_setopt ($curl, CURLOPT_URL, "https://www.google.se/#q=horses"); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec ($curl); curl_close ($curl); if(preg_match_all('#<cite>(.*)</cite>#', $result, $cite)) { foreach($cite[0] as $cite) { echo $cite . '<br />'; } } ?> It doesnt work, I've used this code on other websites to get other things and it works there. What is the problem? Thank you
  15. Hi I am trying to learn regular expression and am getting some unexpected results! $sentence = "This sentence contains several zzz "; if(preg_match("/z{1}/",$sentence)) { echo "Regular expression found!"; } else { echo "Regular expression NOT found!"; } The above code is echoing out “Regular expression found. I am confused. Shouldn't “/z{1}/” return true only if there is only one z in the string not zzz. What am I missing?
  16. hay there How can i check for say 2 or more words in a string... Now I know this checks for 2 words on a "OR" basis if(preg_match("/$findthis|$this/i", $text_to_search)) { //do something } So this ill check to see if the $text_to_search contains either $findthis or $this but i need it to check with the "and" operator - so for example.. search $text_to_search for $findthis and $this how can i do this? many thanks
  17. Can't seem to find a solution to this: I want to use the following readdir code: ++++++++++++ <?php if ($handle = opendir('.')) { while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != ".." && $entry != "sort.php" && $entry != "sort2.php" && $entry != "index.php") { echo "<a href='$entry'>$entry</a><br />"; } } closedir($handle); } ?> ++++++++++++ The above code works perfectly to display all the files in my directory. (All the files to be displayed on my webpage are .pdf files (the code above excludes the .php files in the directory).) These pdf files consist of multiple Catalog_date.pdf, Schedule_date.pdf and Newsletter_date.pdf files, each of which category I want to place in a separate column. To do this, I have three CSS column class <div> sections. I will put the above code in each of the three <div class> sections and exclude two of the three categories depending on which column it is. I was using another code to do this that works perfectly in all respects. It lists the separate categories in separate columns. (see image file below): ++++++++++++ <?php $string = 'Catalog'; echo ""; $PATH = $_ENV['DOCUMENT_WWW']; $d=$PATH.'.'; $files=array(); $dir = opendir($d) or die("couldn't open directory"); while ($f = readdir($dir)) { if (!eregi("\.jpg",$f) && $f!=='.' && $f!=='..' && eregi("$string",$f) && eregi("\.pdf",$f)){ #if does not match .jpg . and .. array_push($files,"$f"); echo "<a href='$f'>$f</a><br>"; } if( is_dir($_dir)) closedir( $d );} ?> ++++++++++++ But "eregi" has been deprecated and I wanted to update my php code to account for this. However, I don't know how to simulate the "f (!eregi("\.jpg",$f) && $f!=='.' && $f!=='..' && eregi("$string",$f) && eregi("\.pdf",$f))" part that allows me to fill the Catalog column with only the Catalog_date.pdf files, etc. (I have attached my currently working page that uses the older code as the example of what I want to do.) Can anyone help me with either including only those files that begin with the word Calendar_, Schedule_ or Newsletter_ for each script; or excluding two of the three files that begin with those words? I have looked at the info in the PHP Manual as well as other Googled places, but don't find enough information to make the code function. Hope this makes sense. Any assistance greatly appreciated. Shelley
  18. I am trying to convert some PHP code, changing all ereg to preg_match but ran into a problem where one of my statements is refusing to cooperate. The statement in question is shown on the first line in the code snippet below: . . if (ereg('^(M?[0-9]{2})/(M?[0-9]{2}|[X]{2})?$',$part,$pieces)) { $tempC = (integer) strtr($pieces[1], 'M', '-'); $tempF = round(1.8 * $tempC + 32); get_wind_chill($tempF, $wxInfo); // Other dependent functions . } The new change to the ereg line I am trying to use is: . if (preg_match('/^(M?[0-9]{2})/(M?[0-9]{2}|[X]{2})?$/',$part,$pieces)) { . The code looks for a string like 30/25 or 08/07 or M01/M11 or 07/M01 - temperatures and dewpoints respectively as reported in METARs - (Meteorological Reports), where M represents the "-" for negative values. The ereg version works perfectly fine and has been doing so for several years. Now that I'm updating the code, adding some new functions and removing deprecated features like ereg, the very last ereg line needing to be changed is mis-behaving. Maybe I am tired and not seeing what else needs to be changed. Could you please tell me what is wrong here why my preg_match version in this remaining line is refusing to work. Thanks in advance.
  19. Can anyone tell me how to fetch all data in specific DIV and inside it is specifec Tag " <p></p>" of given url I Tried this but changing tag names but i Failed please any php expert can me help me ? <?php function getdata($Url){ $str = file_get_contents($Url); if(strlen($str)>0){ preg_match("/\<title\>(.*)\<\/title\>/",$str,$data); return $data[1]; } } echo getdata("http://www.w3schools.com/"); ?> Example URL : www.productsite.com Product Web HTML Example : <div class="products"> <a href="productsite.com" class="title"><strong>Product 1</strong></a><br/> <p>http://www.productsi...1.aspx<br/></p> <br/> </div> <div class="products"> <a href="productsite.com" class="title"><strong>Product 2</strong></a><br/> <p>http://www.productsi...2.aspx<br/></p> <br/> </div> <div class="products"> <a href="productsite.com" class="title"><strong>Product 3</strong></a><br/> <p>http://www.productsi...3.aspx<br/></p> <br/> </div> <div class="products"> <a href="productsite.com" class="title"><strong>Product 4</strong></a><br/> <p>http://www.productsi...4.aspx<br/></p> <br/> </div> <div class="products"> <a href="productsite.com" class="title"><strong>Product 5</strong></a><br/> <p>http://www.productsi...5.aspx<br/></p> <br/> </div> <div class="products"> <a href="productsite.com" class="title"><strong>Product 6</strong></a><br/> <p>http://www.productsi...6.aspx<br/></p> <br/> </div> <div class="products"> <a href="productsite.com" class="title"><strong>Product 7</strong></a><br/> <p>http://www.productsi...7.aspx<br/></p> <br/> </div> and so on ... This Output i need : http://www.productsi...ducatpage1.aspx http://www.productsi...ducatpage2.aspx http://www.productsi...ducatpage3.aspx http://www.productsi...ducatpage4.aspx http://www.productsi...ducatpage5.aspx http://www.productsi...ducatpage6.aspx http://www.productsi...ducatpage7.aspx and so on ...
  20. Hello, I m using the following to check on bad words upon an email validation: $badWords=array('...','...'); $words = array_map('preg_quote', $badWords); $words1 = implode('|', $words); if(!preg_match('/^[a-z0-9_\-\.]+@(?:[a-z0-9_\-]+\.)+(?:'.$Ext.')+$/', $user_email) || preg_match('/\b'.$words1.'\b/i', $user_email){} The email in question: ericbass213...why is it considering it as badword since it snot listed in the badwords array and yes when I ve disabled the badword validation the email workd fine. Thank
  21. I am trying to match only the word "handle" in this Tweet: @testing50037393 @handle 123456 #checkin I am using this regex expression - (?!testing50037393|checkin|\b\d)(\b\w+) I am getting two results of the string "handle" as an array instead of just "handle" once. Please tell me how I can stucture this query to just get one instance of "handle". I am getting this result with preg_match - Array ( [0] => handle [1] => handle ) And this with preg_match_all - Array ( [0] => Array ( [0] => handle ) [1] => Array ( [0] => handle ) ) Thanks, Lela
  22. I am a total beginner at php, and have found a need for preg_match. Even after looking through posts here, this example is still rather beyond me. Can someone point me in the right direction. I have a string $params with the content as below. { "metadata.title": "", "metadata.description": "", "metadata.keywords": "", "metadata.robots": "", "metadata.author": "", "config.enable_comments": "0", "config.primary_category": "311" } How can I extract the value between the "" after the primary_category, in this case 311. Thanks, Alec
  23. keep getting this in my code Warning: preg_match() [function.preg-match]: Unknown modifier 'd' in /home/content/52/9922952/html/sg_contact_content/contact_i51contact.php on line 38 <?php /* This PHP form mailing script created by SiteGrinder 3.1.2 s_239 http://www.medialab.com/sitegrinder3 */ function stripFormSlashes($arr) { if(!is_array($arr)) { return stripslashes($arr); } else { return array_map('stripFormSlashes', $arr); } } if(get_magic_quotes_gpc()) { $_POST = stripFormSlashes($_POST); } if(($_POST['email']=="")) { echo "<html><body><p>The following fields are <strong>required</strong>.</p><ul>"; if($_POST['email'] == ""){ echo "<li>*Email</li>"; } echo "</ul><p>Please use your browsers <a href=\"javascript:history.back();\">Back</a> button and fill out these fields.</p></body></html>"; } else { $message = ""; $message .= "Name: " . htmlspecialchars($_POST['name'], ENT_QUOTES) . "<br>\n"; $message .= "*Email: " . htmlspecialchars($_POST['email'], ENT_QUOTES) . "<br>\n"; $message .= "Inquiring: " . htmlspecialchars($_POST['inquiring'], ENT_QUOTES) . "<br>\n"; $message .= "Comments: " . htmlspecialchars($_POST['comments'], ENT_QUOTES) . "<br>\n"; $lowmsg = strtolower($message); $injection_strings = array ( "content-type:","charset=","mime-version:","multipart/mixed","bcc:","cc:"); foreach($injection_strings as $suspect) { if((preg_match("/$suspect/",$lowmsg)) || (preg_match("/$suspect/", strtolower($_POST['name']))) || (preg_match("/$suspect/", strtolower($_POST['email'])))) { die ( 'Illegal Input. Go back and try again. Your message has not been sent.' ); } } $headers = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: \"" . $_POST['name'] . "\" <" . $_POST['email'] . ">\r\n"; $headers .= "Reply-To: " . $_POST['email'] . "\r\n"; $message = utf8_decode($message); mail("andierue@yahoo.com", "Authentic Health Inquiry", $message, $headers); header("Location: http://www.authentichealthbykate/thank-you.html"); } ?>
  24. Helllo: Need to add the html tag <li>...</li> to this plz: preg_match('/^[a-z0-9_\/a\-\ ]+$/si',$va1) Thanks.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.