Re: [PHP] Help with preg_match_all regex for alt tags

2008-04-29 Thread James Dempster
try preg_match_all('/]*alt="([^"]*)"/i', $subject, $result);

--
/James

On Tue, Apr 29, 2008 at 8:18 PM, Joe Harman <[EMAIL PROTECTED]> wrote:

> Hey y'all ... i am having alittle trouble with this regex for finding
> ALT tags for images...
>
>
> Here is my statement
>
> 
> preg_match_all("'alt[^>]*?>.*?[^>]'si", $output, $alt_tags);
>
> Evaluating
>
> 
> [other html code]...  vspace="2" border="0" alt="Wheel & Tire Acc" /> ...[other html code]
>
> I am currently getting
>
> 
> alt="Wheel & Tire Acc" /><
>
> I want this result
>
> 
> alt="Shopping Cart"
>
>
> Thanks for your help
> --
> Joe Harman
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] Help with preg_match_all regex for alt tags

2008-04-29 Thread Joe Harman
Hey y'all ... i am having alittle trouble with this regex for finding
ALT tags for images...


Here is my statement

preg_match_all("'alt[^>]*?>.*?[^>]'si", $output, $alt_tags);

Evaluating

[other html code]...  ...[other html code]

I am currently getting

alt="Wheel & Tire Acc" /><

I want this result

alt="Shopping Cart" 


Thanks for your help
-- 
Joe Harman

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



Re: [PHP] Help with preg_match_all()

2004-11-01 Thread Klaus Reimer
Curt Zirzow wrote:
And so on.. It's a kind of a template system... well... I need to
create a expression to get all the tags from the HTML with
preg_match_all() in order to have them in a array...
So your looking from something that starts with '{' and continues
while not a ')' ...
  /{([^}]*?)}/
If you are already using the "?" meta character then you can simply do this:
/{(.*?)}/
The "while not"-approch is useful if you don't want to use the "?" meta 
character (to be compatible to regex engines which don't support this). 
But then it would look like this:

/{([^}]*)}/
But all these expressions are to lazy for the required work. The tags 
should be matched more exactly using this:

/{$([\w\.]+)}/
This implies that the variable names always begin with a dollar 
character and they can contain upper and lowercase characters, numbers, 
underscores and periods. The variable name must contain at least one 
character, so {$} is not matched.

--
Bye, K  (FidoNet: 2:240/2188.18)
[A735 47EC D87B 1F15 C1E9  53D3 AA03 6173 A723 E391]
(Finger [EMAIL PROTECTED] to get public key)


signature.asc
Description: OpenPGP digital signature


Re: [PHP] Help with preg_match_all()

2004-10-31 Thread Francisco Javier Escoppinichi Fernández
Thanks!

Worked like a charm!

*Problem solved*


On Mon, 1 Nov 2004 03:01:12 +, Curt Zirzow
<[EMAIL PROTECTED]> wrote:
> * Thus wrote Francisco Javier Escoppinichi Fernndez:
> > Hello people...
> >
> > I'm relatively a beginner with regular expressions, so I need a little
> > help here.. I hope you can help me...
> 
> If you read the whole section @ http://php.net/pcre you'll be able
> to do this in your sleep.
> 
> >
> > Ok, I have a HTML file with several tags like this:
> > {$base.username}
> > {$base.date}
> > {$blog.lastpost}
> >
> > And so on.. It's a kind of a template system... well... I need to
> > create a expression to get all the tags from the HTML with
> > preg_match_all() in order to have them in a array...
> 
> So your looking from something that starts with '{' and continues
> while not a ')' ...
> 
>   /{([^}]*?)}/
> 
> Curt
> --
> Quoth the Raven, "Nevermore."
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
Francisco Javier Escoppinichi Fernández
Email: [EMAIL PROTECTED]
Web: http://www.fire-dragon.net/
MSN: [EMAIL PROTECTED]
Cel: 044 (612) 348 91 00

"Sólo hay 3 cosas que no vuelven atrás: la palabra emitida, la flecha
lanzada y la oportunidad perdida."

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



Re: [PHP] Help with preg_match_all()

2004-10-31 Thread Curt Zirzow
* Thus wrote Francisco Javier Escoppinichi Fernndez:
> Hello people...
> 
> I'm relatively a beginner with regular expressions, so I need a little
> help here.. I hope you can help me...

If you read the whole section @ http://php.net/pcre you'll be able
to do this in your sleep.

> 
> Ok, I have a HTML file with several tags like this:
> {$base.username}
> {$base.date}
> {$blog.lastpost}
> 
> And so on.. It's a kind of a template system... well... I need to
> create a expression to get all the tags from the HTML with
> preg_match_all() in order to have them in a array...

So your looking from something that starts with '{' and continues
while not a ')' ...

  /{([^}]*?)}/



Curt
-- 
Quoth the Raven, "Nevermore."

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



[PHP] Help with preg_match_all()

2004-10-31 Thread Francisco Javier Escoppinichi Fernández
Hello people...

I'm relatively a beginner with regular expressions, so I need a little
help here.. I hope you can help me...

Ok, I have a HTML file with several tags like this:
{$base.username}
{$base.date}
{$blog.lastpost}

And so on.. It's a kind of a template system... well... I need to
create a expression to get all the tags from the HTML with
preg_match_all() in order to have them in a array...

Can you help me with this.. I already Googled for that, but I really
don't understand too well :P

-- 
Francisco Javier Escoppinichi Fernández
Email: [EMAIL PROTECTED]
Web: http://www.fire-dragon.net/
MSN: [EMAIL PROTECTED]
Cel: 044 (612) 348 91 00

"Sólo hay 3 cosas que no vuelven atrás: la palabra emitida, la flecha
lanzada y la oportunidad perdida."

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