Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2007

Tip: Looking for answers? Try searching our database.

RegEx Help

Thread view: 
vunet.us@gmail.com - 17 Jul 2007 16:28 GMT
Please, assist with RegEx which reads String object and gets SRC of
all HTML IMG tags. This code does it but it returns "<img src='"
prefix in front of it if using (/<img[^>]+src=('|")([^'"]+)/ig).
Thanks.

JavaScript:

var strText = "ab cd efg hig klmnop <img src='file.jpg'> ot her"+
 " e <IMG SRC='www.g.com/file2.jpg' BORDER=0>";

 var separateBy = "\n";
 var result = ""; // if no match, use this
 var allMatches = strText.match(/<img[^>]+src=('|")([^'"]+)/ig);
 if (allMatches) {
   result = "";
   for (var i = 0; i < allMatches.length; i++) {
      if (i != 0) result += separateBy;
         result += allMatches[i];
      }
 }
 alert(result)
}
Paul Tomblin - 17 Jul 2007 17:55 GMT
In a previous article, vunet.us@gmail.com said:
>JavaScript:

Wrong newsgroup.

Signature

Paul Tomblin <ptomblin@xcski.com> http://blog.xcski.com/
Science is like sex: sometimes something useful comes out, but that's
not why we're doing it.
             -- Richard Feynman

Daniel Pitts - 18 Jul 2007 21:01 GMT
On Jul 17, 8:28 am, vunet...@gmail.com wrote:
> Please, assist with RegEx which reads String object and gets SRC of
> all HTML IMG tags. This code does it but it returns "<img src='"
[quoted text clipped - 19 lines]
>
> }

This is a Java newsgroup, not a JavaScript newsgroup.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.