Re: [PHP] Re: regex help needed -- Solved! Thanks!

2004-08-02 Thread Fabrice Lezoray
Kathleen Ballard a écrit :
Thanks!  Works like a charm!
I am the very lowest of newbies when it comes to regex
and working through your solutions has been very
educational.  I have one question about something I
couldn't figure out: 

#(.*)#Uie
`.*?`sie
What is the purpose of the back-ticks and the '#'? 
PCRE patterns has to be enclosed, you can use all the non alpha numerics 
characters to do that. Personnaly, I prefer back ticks because I don't 
have to escape it often inside my patterns.
For my example, you can also remove the ``s pattern modifier, It makes 
the dot ( . ) accept any New line characters, and I had not see  that 
you removed them before.

What are 'Uie' and  'sie'?
there are patterns modifiers, you can find a complete list and 
descriptions here :
http://www.php.net/manual/en/pcre.pattern.modifiers.php


Thanks again!
Kathleen
-Original Message-
From: Fabrice Lezoray [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 01, 2004 2:52 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: regex help needed 

hi
M. Sokolewicz a écrit :
You could try something like:
$return = preg_replace('#(.*)#Uie',
'str_replace("

/>", "", "$1")');
- Tul
Kathleen Ballard wrote:

Sorry,
Here is the code I am using to match the  tags:
.*
I think this mask is better :
`.*?`sie

I have removed all the NL and CR chars from the
string
I am matching to make things easier.  Also, I have
run
tidy on the code so the tags are all uniform.
The above string seems to match the tag well now,
but
I still need to remove the br tags from the tag
contents (.*).
To remove the  tags, you need to call
preg_replace_callback() :

$str = 'hi  .. bla bla   
.. ...';
function cbk_br($match) {
	return '' . str_replace('',
'', $match[2]) . 
'';
}
$return =
preg_replace_callback('`(.*?)`si',
'cbk_br', 
$str);
echo $return;
?>

The strings I will be matching are html formatted
text.  Sample  tags with content are below:
Ex-Secretary Mickey Mouse Loses Mass.
Primary
Ex-Secretary Mickey Mouse Loses Mass.
Primary  Wins New Jersey
Ex-Secretary Reich Loses Mass. Primary
Again, any help is appreciated.
Kathleen


Sorry for my bad english ..
--
Fabrice Lezoray
http://classes.scriptsphp.fr
-
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Re: regex help needed -- Solved! Thanks!

2004-08-01 Thread Kathleen Ballard

Thanks!  Works like a charm!

I am the very lowest of newbies when it comes to regex
and working through your solutions has been very
educational.  I have one question about something I
couldn't figure out: 

#(.*)#Uie
`.*?`sie
What is the purpose of the back-ticks and the '#'? 
What are 'Uie' and  'sie'?

Thanks again!
Kathleen

-Original Message-
From: Fabrice Lezoray [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 01, 2004 2:52 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: regex help needed 

hi

M. Sokolewicz a écrit :
> You could try something like:
> $return = preg_replace('#(.*)#Uie',
'str_replace(" />", "", "$1")');
> 
> 
> - Tul
> 
> Kathleen Ballard wrote:
> 
>> Sorry,
>> Here is the code I am using to match the  tags:
>>
>> .*
I think this mask is better :
`.*?`sie


>>
>> I have removed all the NL and CR chars from the
string
>> I am matching to make things easier.  Also, I have
run
>> tidy on the code so the tags are all uniform.
>>
>> The above string seems to match the tag well now,
but
>> I still need to remove the br tags from the tag
>> contents (.*).
To remove the  tags, you need to call
preg_replace_callback() :

hi  .. bla bla   
.. ...';
function cbk_br($match) {
return '' . str_replace('',
'', $match[2]) . 
'';
}
$return =
preg_replace_callback('`(.*?)`si',
'cbk_br', 
$str);
echo $return;
?>

>>
>> The strings I will be matching are html formatted
>> text.  Sample  tags with content are below:
>>
>> Ex-Secretary Mickey Mouse Loses Mass.
>> Primary
>>
>> Ex-Secretary Mickey Mouse Loses Mass.
>> Primary  Wins New Jersey
>>
>> Ex-Secretary Reich Loses Mass. Primary
>>
>> Again, any help is appreciated.
>> Kathleen


-- 
Fabrice Lezoray
http://classes.scriptsphp.fr

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php