0

I want RE for this string pattern:

src="http://www.prphotos.com/f/1335/CSM-001335/Robert-Pattinson,-Reese-Witherspoon-Water-for-Elephants-New-York-City-Premiere---Arrivals.jpg"  border="0"

I am using:

<img.[\w+\s+\d+\W]*/>

Also do I have to write different RE for different languages like javascript,PHP etc?

3
  • 1
    I would use a real dom parser. But hey. Commented Apr 19, 2011 at 6:35
  • The usual approach for this is to use a HTML parser. What is your use case? What kind of data are you searching in? Commented Apr 19, 2011 at 6:35
  • 1
    The question is ambiguous: Are you trying to match any image tag, only image tags with src="..." and border="...", only image tags from prpphotos.com, only image tags of a certain type from this particular site, etc.? Commented Apr 19, 2011 at 6:37

1 Answer 1

1
<img [^>]*src=".*?[^\]"[^>]*/>

You may need to write \ as \\

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks alot it worked, now I just wanna extract src, or can it return in array so I can use src.
that modification will cause a parse fail if there is a url with "s inside

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.