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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:36:21+00:00 2026-05-15T03:36:21+00:00

Before you say oh no, not again here I’m stating my case. I’m parsing

  • 0

Before you say “oh no, not again” here I’m stating my case. I’m parsing part of HTML output and the only thing I’m interested in is name and value attributes of each <input/> tag. HTML is actually HTML fragment, may not be well-formed. I don’t have DOM or HTML parser and I don’t try to parse nested elements anyway. The problem is that I don’t know the order or number of attributes so it could be <input name="foo" value="boo"/> or <input type="hidden" name=foo> or <input id=blah value='boo' src="image.png" name="foo" type="img"/>.

Is there a single regular expression that would get me values of name and value attribute in predictable order? I wouldn’t have asked the question if I could assume that name attribute always precedes value but unfortunately this is not the case

  • 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-15T03:36:22+00:00Added an answer on May 15, 2026 at 3:36 am

    To get the values of name and value into the same capturing group, regardless of order, you could try

    <input (?=[^>]* name=["']([^'"]*)|)(?=[^>]* value=["']([^'"]*)|)
    

    if your regex implementation supports lookaheads.
    This assumes that the values are quoted.

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

Sidebar

Related Questions

I'm not sure exactly what went wrong here, but ReSharper 4.5 RTM seems to
I am not sure if this is Java behaviour or rogue GWT behaviour. But
I found the following rather strange. Then again, I have mostly used closures in
Once again I find myself failing at some really simple task in C++. Sometimes
I'm still plagued by background threading in a WinForm UI. Why? Here are some
The basic idea is very easy. Simplified you could say... a snake like line
I am having the weirdest error. If anyone can give me hints, I've found
I recently had a question answered about a multi-computer git development setup, and the
What naming convention is recommended when writing an MVC app that has both front-end

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.