electron
Jul 30 2006, 04:23 PM
Hi, I got a new problem which has caused me to go mad but no solution. preg_match_all() - is the problem. I have something like this: CODE [ol] [li]Test1[/li] [li]Test2[/li] [li]Test3[/li] [li]Test4[/li] [li]Test5[/li] [/ol]
Some text.Some text.Some text.
[ol] [li]Test1[/li] [ol] [li]Test1[/li] [li]Test2[/li] [li]Test3[/li] [li]Test4[/li] [li]Test5[/li] [/ol] [li]Test2[/li] [li]Test3[/li] [li]Test4[/li] [li]Test5[/li] [/ol]
My RegExp is the following: CODE preg_match_all("/(\[ol\])(.*)(\[\/ol\])/iUx", $text, $matches, PREG_SET_ORDER);
Now this function gets 2 matches from the given text : Match 1:CODE [ol] [li]Test1[/li] [li]Test2[/li] [li]Test3[/li] [li]Test4[/li] [li]Test5[/li] [/ol] Match 2:CODE [ol] [li]Test1[/li] [ol] [li]Test1[/li] [li]Test2[/li] [li]Test3[/li] [li]Test4[/li] [li]Test5[/li] [/ol] It takes the [/ol] of the nested element first.I wanted that the preg_match_all() function matches the second match including the nested OR it should give me three matches. If i use Greedy RegExp then it takes the whole thing as One Match including the text between the two seperated [OL]'s. Is my REGEXP wrong or something.I tried lookaheads also but nothing.Please help me with this. I need it . This thing is going in my mind and does not let me live with peace. Thanks and have a good day.
Reply
Similar Topics
Keywords : regexp, function, preg, match, all, preg, match, all
- A Simple Preg_replace Help Please.
(1)
Question Regarding Php Function
It's all about PHP mail (12) I found out many people recommend Trap 17 as their free webhost, and I'm interested too! My
experience with all free host is having PHP Mail function disabled (and need to choose premium/paid
package to enable it) /sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif"
/> . Do Trap17 enable php mail function? Because it will be very useful for me as I creating a
bulletin board (forum). Thank you for answering /biggrin.gif" style="vertical-align:middle"
emoid=":D" border="0" alt="biggrin.gif" /> .....
Preg Replace Problem
(1) If i have a word like c.........a......t (with the dots in) and i wanted to replace it with cat how
would i do it. If i use CODE <?php $patterns =
"/c(*)a(*)t/"; $replace = "cat"; echo
preg_replace($patterns, $replace, 'c.....a.........t');
[/color][color="#000000"]?> then when i type something like "
c ome a nd look at t his" is also filtered. Is
there any way just to filter cat with dots in? ....
Php Preg Replace
(1) Ive got a problem with preg replace, this is the code: display.php CODE <table
border="1"> <tr><th width="70">Time</th><th
width="200">IP</th><th
width="70">Viewed</th></tr> <?php $LogData =
file_get_contents("log.txt"); $Find =
"/||(.*)|(.*)|(.*)||/i"; $Replace =
"<tr><td>$1</td><td>$2</td><td>$3
</td></tr>"; ....
I Don't Think Anyone Can Match This!
(3) If you wanna hear a crazy story about what happened to me today, then get ready cuz it's kinda
funny =) I was at the beach with a bunch of friends that I've known for a long time. And it
was during a hurricane. So we went out to swim into the ocean (like the dumbasses we are) and
almost drown to death. THE END /tongue.gif" style="vertical-align:middle" emoid=":P" border="0"
alt="tongue.gif" /> I wanna hear some crazy stories too so lete me hear them!....
Endif function?
(6) As you get noticed before, I am studying PHP in examples like using the tutorials as well as books
itself. Through my readings, I get this function CODE <?php endif; ?> a lot of times.
So, what do you mean by this function, and what does it do exactly?....
Php - Forms, Date And Include
Working with POST and GET and also the Date() function (0) /--------PHP FORMS, DATE AND INCLUDE TUTORIAL BY FLASHY--------\ Hi and welcome to my
tutorial. I will show you how to make simple PHP forms with the POST and GET statements. I will
also show show you the Date() function too, aswell as the include() function. OK, so first you need
a good understanding of HTML, and you need to create your form using that. So lets start off with
the HTML form. 1. Create a page called form.html. 2. Insert your standard tags like: CODE
<html> <head> <title>Working with php forms.</title> </he....
User Permission Function [php]
Determining User Permissions (3) There have been several recent request for methods to restrict access to various pages on a web-site
based on User Permissions in sites that have a Login System in place. Here is some code showing one
method to restrict access by providing a sub-set of your site's links based on the User's
permissions. In this demonstration, I have defined a string for each 'level of user'
determining which set(s) of links they can view on your site. Normal MySql procedure would be to
read the User's permission level from a record in the database. For the purpose of ....
Help: Disable All Buttons Inside A Div Element
How do you write a function to disable all buttons given a div id (8) I need help to write a function to disable all buttons iside a div ID. if possible the function will
disable all buttons even the ones inside child divs belonging to the main div.....
Inkscape, A Open Source Vector App That Support Lot Function.
An Open Source vector graphics editor, with capabilities similar to Il (0) It is common now for using graphics design tools like Adobe Creative Suite, Canvas, CorelDraw etc.
But it will be high cost. Here has a free open source tool that do most of the work without cost.
It's called Inkscape. You can work with it like other common apps such as align, layer, export
to gimp with svg and even more. Screen Shot : URL : www.inkscape.org Sample:
www.openclipart.org Some Tutorial : blip.tv/file/316576 ....
Arrays Outside A Function
Need to have arrays available to all functions. (3) I've got a bunch of arrays that i want to use for more then 1 function. when i declear the
arrays outside a function i cant use it in a function. This code was originally written in
javascript by another person but since I plan to use it and extend it with php I had to change it
from javascript to php code. In the javascript code the arrays were decleared outside the functions
with 'var arrayname' I read somewhere that declearing javascript variables with
'var' gives it global access. Any ideas on how I can go about declearing 1 set of these
arrays t....
Problem With Where Clause And Max Function
Problem with where clause and max function (2) i have a column in a table which is varchar format but contains timedate type data eg. '24/7/07
05:32 PM'. I'm trying to run a query which uses a where clause to only return the rows where
this column is equal to the most recent date. I've tried using the MAX() function which returns
a valid result but not the most recent date. ....
How To Check If Fsockopen Function Is Enabled?
(2) Hi, I have VPS (virtual private server) and I have access to php.ini file. Is there any script that
will show that fsockopen function is enabled or where do I have to enable it? Searched google and
here and couldn't find anything. Thanks! ....
Php Explode Function Help
(4) I am having trouble creating a script, all i want to achieve is to: 1. Select the variable from my
mysql database, which is in a format of : id|id|id|id| and so on... 2. Split them into separate
variables by using : $songexploded = explode("|",$ttyo ); 3. Then this is the bit I'm
stuck on trying to create a while loop from the $songexploded variables. So(this might not be
correct but you should get the idea).. CODE $x=1; while ($songexploded
==$result) echo $songexploded[$x].'<br>'; }....
Validation Script - Detecting Illegal Characters
preg_match to find illegal characters (0) I'm trying to validate a user's desired username for a registration page. I want to detect
any illegal characters being used for a username. So far i have managed to include most execpt the
'\', the '\' is used for escape and treating the preceding characters
literally. I try to do '\\' but i get an error because it execects another
character. CODE $ck_result = "Default"; $pattern =
"/[!|@|#|$|%|^|&|*|(|)|_|\-|=|+|\||,|.|\/|;|:|\'
;|\"|....
The Best Zip Function
(1) hi my 6th code is very useful, you can zip your file by this: CODE <? class dZip{ var
$filename; var $overwrite; var $zipSignature =
"\x50\x4b\x03\x04"; // local file header signature var
$dirSignature = "\x50\x4b\x01\x02"; // central dir header signature
var $dirSignatureE= "\x50\x4b\x05\x06"; // end of central dir
signature var $files_count = 0; var $fh; Function
dZip($filename, $overwri....
Mail() Clone
A PHP mail() function clone (5) A lot of free web hosts have disabled the mail() function so you cannot send emails using PHP. Does
anybody know of a script that makes a function "like" mail but is able to be installed in a web
accessible directory and called included into another script and called like that? Or maybe you know
how to make such a function? I just really need to find a way around the free hosts turning of the
mail() function. I need to figure out a way to send emails.....
[php](simple) Using Functions To Combine Values In A Form
Really simple example on how to combine values with function (2) I just learned this simple method on how to use functions to combine two values from a form. First
we create ourselves a simple POST form CODE <form method="POST"> Name:
<input type="text" name="nickname"> Location: <input
type="text" name="location"> <input type="submit"
value="Input"> </form> Now we add this php to that same file CODE
<?php $nick = $_POST['nickname']; $location =
$_POST['location' ....
[php] Header Function
(2) Header function Greetings we are going to use the header() funtion to redirect start making a
file called page.php at the top of the file add CODE <?php ?> Example 1 After
CODE header('Location: http://www.trap17.com'); the LOCATION means
where you want it to go. Example 2 you also can define a file that you want to redirect to After
CODE header('Location: index.php'); Example 3 you also can add a timer to
it /laugh.gif" style="vertical-align:middle" emoid=":lol:" border="0" alt=....
Php - Randomize Web Title
using arrays and the random function (5) PHP - Randomize Web Title with the rand function... Define the variables numbers we start at number
0 CODE <?php $title[0] = "Web title 0"; // Title 0
$title[1] = "Web title 1"; // Title 1 $title[2] = "Web title
2"; // Title 2 $title[3] = "Web title 3"; // Title 3
$title[4] = "Web title 4"; // Title 4 ?> now we use the rand()
function to get a randomize the web title. rand(0, 4) means we start at 0 and end at 4 i can get
0,1,2,3,4 one of those. ....
Error With Joomla Template
cant find function (1) Hello! I am working on my template in Dreamweaver and i am using joomla extensions for
dreamweaver! When i start my page with joomla stand alone server(jsas) i get this errors on the
bottom of the page! QUOTE Warning:
mosloadcomponent(w:/www/Joomla/components/com_banner/banner.php) : failed to open stream: No such
file or directory in w:\www\Joomla\includes\frontend.php on line 66 Warning:
mosloadcomponent(w:/www/Joomla/components/com_banner/banner.php) : failed to open stream: No such
file or directory in w:\www\Joomla....
Using The / As A Delimiter In The Split Function
using the / as a Delimiter in the split function (2) How do I use the / as a Delimiter in the split function? This is the code now: CODE
($url1, $url2, $url3) = split (/\./,$Image_Upload_4);
This is what I want to be able to split up the url: CODE ($url1, $url2,
$url3) = split (/\/./,$Image_Upload_4); I have tried to put the / in
quotes but that did'nt work. Thanks for any help.....
The Extract() Function
Something I just found out (6) The extract() function is used in PHP to take an array and split it up into variables. MySQL
queries can be parsed this way. Below is an example. CODE $query =
mysql_query("select username, password from users where uid=1"); $result =
mysql_fetch_array($query, mysql_assoc); extract($result); print "Your
username is : $username"; The extract() function works for ANY array, including
$_POST, and $_GET. Makes processing form data a LOT easier /biggrin.gif"
style="vertical-align:midd....
How Good Is This Data Cleaning Function?
(2) Hi all, this is my first function and as part of a script and i just want to know a couple of
things. here is the code for the function: CODE <? function
clean($dirty_string) { $muddy_string = stripslashes($dirty_string);
$murky_string = strip_tags($muddy_string); $clean_string =
htmlentities($murky_string); }; ?> So the first thing is how secure is
it? the script this will be used in connects to a database and sends an email so it needs to stop
SQL injections and any email ab....
Genuine Help With Smtp And Php Mail() Function
I need help using the PHP mail() function and the SMTP server on Trap1 (3) Hello, I have looked up the solution to this problem numerous times on this forum but cannot seem to
get a straight answer. I have also read that something called SMTP Authetication is required. I have
looked up numerous ways this should be done, but I believe it required special protocols. This is
the code that I tried to use to send e-mail using the SMTP server here at Trap17. CODE
$email_to = "whoever@whoever.com"; //SEND MAIL TO HERE $subject = "Testing the
SMTP server"; $message = "This is a test of the SMTP server on T....
Include File.php?id=something
using the include() function (13) Well, I am making a full CMS system for my site, and want to make the index.php file to include the
view.php?id=1 file. I tried with this code, but it didn't work: CODE <?php include
'view.php?id=1' ?> This is the error I get: CODE Warning:
main(view.php?id=1) [function.main]: failed to open stream: Invalid argument
in C:\server\xampp\htdocs\test\index.php on line 1 Warning:
main() [function.include]: Failed opening 'view.php?id=1' for inclusion
(i....
How To Use A Link To Call Function In Php?
(8) The title says it all, really. How do you call a function using in PHP? I'm doing a project
and I stumbled upon this problem. I don't want to use query string in the href part like
since that would mess up the other part of my code. Can anyone pleae help me? I've pasted the
code below. /smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /> Thanksh.
CODE <?php function display($x){ //coding goes here. } ?>
<html> <body> <p align="center"> <a href="what g....
Magic Match
(1) QUOTE Magic Match Magic Match is a rich puzzle game with an enchanting fantasy theme.
Explore six mystical realms in the Lands of the Arcane with Giggles your helper imp by your side.
Earn magical bonus spells as you journey through 126 story levels in this wonderfully engrossing
experience! Beautifully sung cut-scenes presenting a captivating story, over 22 power-ups and
special features. * Over 100 story mode levels with three difficulties * Six magical realms
* Exciting rewards including bonus rounds Download comment: for me, thats a g....
Getting List Of Directories And Files Using Php
PHP Function for Directory and File List (6) is there a php function that lists the content of some folder.... example: /New folder new.txt
left.gif download.zip dc.exe ....so is there..? /rolleyes.gif' border='0'
style='vertical-align:middle' alt='rolleyes.gif' /> ....
Delphi
Simple Text Parsing Function (1) Because parsing is such an integral part of string manipulation, I took the time to make a quick and
simple parse function. For you VBers, Delphi is a derivative of Pascal...it's powerful, simple,
and (best of all) doesn't need external component (eg: ocx files). Hence the code: Code:
function TForm1.SimpleParse(MainString, BeginString, EndString: string): string; var PosBeginString:
integer; PosEndString: integer; begin PosBeginString := Pos(BeginString, MainString) +
Length(BeginString); PosEndString := Pos(EndString, MainString); Result := Copy(MainString, ....
Looking for regexp, function, preg, match, all, preg, match, all
|
|
Searching Video's for regexp, function, preg, match, all, preg, match, all
|
advertisement
|
|