Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

PHP Regular Expressions

New Here ,
Jul 22, 2006 Jul 22, 2006
I am trying to write a script that searches for image tags and checks for alt tags within them. I am using preg_match_all to find all the img tags but i am messing up somewhere on my regular expression pattern.

I seriously just started learning these expressions days ago so i really do not know what i am doing here. For some reason my current expression: /<img.+\/>./ Doesnt find the next > after finding the first <img tag. It gets like the second or third one. Shouldnt it cut it off after it finds the first >?

In addition, my other expression (for extracgting the src tag doesnt stop after the second quatation. Insead it goes for a few more. /src=\".*\"/ is what i have now.

What do i need to fix so that the results i get back dont include anything after the first > or the second quation mark?
TOPICS
Server side applications
254
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 23, 2006 Jul 23, 2006
LATEST
barbedwire103 wrote:
> What do i need to fix so that the results i get back dont include anything
> after the first > or the second quation mark?

/<img[^>]+>/

/src\s?=\s?"[^"]+"/

--
David Powers
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "Foundation PHP 5 for Flash" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines