Welcome Guest ( Log In | Register )



2 Pages V  < 1 2  
Reply to this topicStart new topic
> Php Regular Expressions, Request For Help.
overture
post Apr 15 2005, 01:05 PM
Post #11


Premium Member
Group Icon

Group: Members
Posts: 208
Joined: 6-September 04
From: England
Member No.: 315



lol yes i did Viz smile.gif
Go to the top of the page
 
+Quote Post
^zer0dyer$
post May 2 2005, 08:02 AM
Post #12


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 4
Joined: 2-May 05
From: Alpha Centauri
Member No.: 4,636



First of all, if you are just trying to escape HTML characters use:
-htmlentities() OR
-htmlspecialchars()
which are built-in PHP functions. If you are just trying to learn regexp, more power to you! cool.gif

In PCRE regular expressions, there are several types of delimiters you can use for your patterns
CODE
<?php
# This finds all tags
$pattern = "@<\w+?[^>]>@is"; // @ is the delimiter in pattern.
?>

That was a very eloquent pattern, mastercomputers. I just recently started using look aheads/behinds, and have had fun toying around with them smile.gif

Also, if you want to print out mastercomputers' result with preg_match, try the following for some good practice:
CODE
<?php
$file = "path/to/file";
$handle = @file_get_contents($file) or die("File not acquired!\n</body>\n</html>");
// This is safer!

$pattern = "#Latest\sMember:\s.+?(?=\s)#i";

if ( preg_match($pattern, $handle, $matches) )
{
  print "<pre>\n".print_r($matches)."\n<pre>\n";
}
else
{
  print "<p>Nothing found =(";
}

# Finds all matches
if ( preg_match_all($pattern, $handle, $matches) )
{ # $matches is now a 2-dimensional array
  print "<pre>\n".print_r($matches)."\n</pre>\n";
}
else
{
  print "Nothing found =(";
}
?>


Peace,
+CurTis-
Go to the top of the page
 
+Quote Post

2 Pages V  < 1 2
Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Not A Hosting Request...(26)
  2. Airtel GPRS(23)
  3. Request A Signature(18)
  4. Ssl Request(1)
  5. Password Reset Request (silverfox)(3)
  6. Request To Change Some Server Settings(4)
  7. Restore Full Backup Request(2)
  8. Request For Free Web Hosting And Cpanel - denied(1)
  9. Wierd Problem With $_post/$_get/$_request(11)
  10. The Absolute Bare Minimum Every Programmer Should Know About Regular Expressions(1)
  11. Hipergate Installation Services Required(1)
  12. I Would Like To Request Free Web Hosting From Astahost.(3)
  13. Free Hosting Request (squidoctober.astahost.com)(1)
  14. Request For Subforum - Solaris(3)
  15. How Long Request Should Be Granted?(5)
  1. Changing Of Hosting Credit To Normal Forum Credit(1)
  2. Script Request(2)
  3. Filtering Out Unwanted Junk Mail Using Regular Expression.(0)
  4. Regular Expressions Not Matching(4)
  5. Free Web Host Request For Sup3r501d13r - denied(2)
  6. Using Regular Expressions To Parse Functions(6)
  7. My Request For New Account No Replay Abdomahdy(1)
  8. Not A Request(1)
  9. Heren Istarion Request(2)
  10. Request Form Site Suspended(4)
  11. Regular Expressions(6)
  12. Need Help?(9)
  13. Freewebhosting: Ml01172.astahost.com(2)


 



- Lo-Fi Version Time is now: 1st December 2008 - 05:06 PM