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 7525383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:31:47+00:00 2026-05-30T03:31:47+00:00

I was going over a piece of code, and i came across this regular

  • 0

I was going over a piece of code, and i came across this regular expression

Regex _fileOrImageRegex = new Regex("<\\s*(?<Tag>(applet|embed|frame|iframe|img|link|script|xml))\\s*.*?(?<AttributeName>(src|href|xhref))\\s*=\\s*([\\\"\\'])(?<FileOrImage>.*?)\\3", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline);

Can someone please explain me the expression in plain words. Its been used to parse all the images, i get that part, i also want to modify the regular expression to include the alt tag for every image tag it matches.

thanks

  • 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-30T03:31:48+00:00Added an answer on May 30, 2026 at 3:31 am

    Required link: RegEx match open tags except XHTML self-contained tags

    In English, what it does is this:


    < matches a HTML open tag

    \s* matches any amount of whitespace (tabs, spaces, newlines)

    (? is something to not worry about – it’s a subgroup but it doesn’t store the value

    The next lump is possible values for open tags – applet, embed, etc

    The () around the values mean “store this value in a subpattern, and make it available as
    part of my results

    The | means “or”, so applet or embed, etc – this looks at tag names

    \s* more whitespace

    .? means “any amount of anything”, except for newlines but because of the SingleLine flag (see comments for this answer) is matches “any amount of anything”

    (? again, see above, same for the optional values (src, href) – these are the tag
    attributes

    \s=\s* means “a space, followed by an equals sign, followed by any amount of whitespace”

    ([\\"\\']) the (), see above. The [] mean “any of these characters, in any order”, and the \\" and \\' are the ” and ‘ characters, escaped with backslashes

    (?.?) we already know (?, and the .? means “optionally, a single one of any character”


    The options at the end are modifiers, they make the regex match more things – IgnoreCase makes it case insensitive, Singleline should be obvious, and someone else will tell you what Compiled means, because I don’t know the language the regex is written for 🙂


    Edit: You’ve just updated the first post a little. The <Tag> and <AttributeName> give the match groups a name, so for example, your result of running the regex might look like this:

    Array
    - Tag = img
    - AttributeName = src
    - FileOrImage = http://www.mysite.com/a.png
    

    By the way, congratulations on having an awesome name 😀

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

Sidebar

Related Questions

I have been going over rails scheduling tasks options and stumbled upon this piece
Been going over my predecessor's code and see usage of the request scope frequently.
I've been going over and over this in my head, and I can't seem
I am going over/studying the facebook code that was leaked in 2007, I notice
I've moved to a new project team and while going over the codebase, found
I'm going over some C++/CLI material and I've come across the concept of a
I am going through a piece of code for packet injector. When I tried
So we start Scrum today and start going over story points estimates. The first
I'm going back over an old project where I added preprocessor functionality to Essence'
When I iterate over the values or keys are they going to correlate? Will

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.