Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6228169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:20:33+00:00 2026-05-24T09:20:33+00:00

I used this regex expression to search for img src in a string in

  • 0

I used this regex expression to search for img src in a string in one on my site.
Now I wan’t to use this expression to do the same thing in objective c. How can I do that using RegexKitLite?
This is my expression

/<img.+src=[\'"]([^\'"]+)[\'"].*>/i

@Tim Pietzcker

Your code works great but for example if I try to search img in this string

<p><a href="http://www.nationalgeographic.it/popoli-culture/2011/08/03/news/per_la_tomba_del_boia-443612/?rssimage"> <img src="http://www.nationalgeographic.it/images/2011/07/29/115624013-20034abf-4d91-40fe-98ab-782f06a9854d.jpg" width="140" align="left" hspace="10"></a>Scoperta in America del Sud la sepoltura pre-incaica di un uomo circondato da coltelli cerimoniali che secondo gli archeologi eseguiva sacrifici umani</p>

I have this result in my array:

matchArray: (
    "<img src=\"http://www.nationalgeographic.it/images/2011/07/29/115624013-20034abf-4d91-40fe-98ab-782f06a9854d.jpg\" width=\"140\" align=\"left\" hspace=\"10\">"
)

How can I mod your regex to only get the content of src tag? thank you so much

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:20:34+00:00Added an answer on May 24, 2026 at 9:20 am

    The / delimiters are throwing you off. Also, you should at least use lazy quantifiers. Try this:

    NSString *regexString = @"(?i)<img.+?src=['\"]([^'\"]+)['\"].*?>";
    

    This breaks when filenames contain quotes, by the way. Could that be a problem for you?

    A regex that’s a bit safer (and that handles quotes well) would be

    NSString *regexString = @"(?i)<img[^<>]+?src=(['\"])((?:(?!\\1).)+)\\1[^<>]*>";
    

    However, now the matches filename will be in capture group 2, not 1, so you need to modify any code that uses the filename after the match.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is one of the most used Regex functions Regex.IsMatch(Test text for regex test.,
What would be the regex expression to find (PoundSomenumberSemiColonPound) (aka #Number;#)? I used this
This regex comes from Atwood and is used to filter out anchor tags with
Till this moment I used this method to invoke: public string AddText { set
One of our developers used this call: TzSpecificLocalTimeToSystemTime() but unfortunately we cannot keep it
I am having problems trying to use the regular expression that I used in
Is there a way to rewrite this regex expression such that it does not
I used an online regular expression (regex) tester to build a simple regex, however
I am being struggling with this regex expression long time but i cannot find
I am trying to use this expression: Expression: \w{1,}\s*?\-\-(\>)?\s*?\w{1,} Keep in mind I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.