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

  • Home
  • SEARCH
  • 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 8605993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:59:09+00:00 2026-06-12T02:59:09+00:00

html source <form> <input type=text name=a value=a1fa4 type=hidden/> <input type=text name=b value=b1fa9 type=hidden/> <input

  • 0

html source

<form>
<input type="text" name="a" value="a1fa4" type="hidden"/>
<input type="text" name="b" value="b1fa9" type="hidden"/>
<input type="text" name="c" value="c1fd2" type="hidden"/>
<input type="text" name="d" value="d1fx1" type="hidden"/>
</form>

php source

<?php
  preg_match_all('/<input name="(.*?)" value="(.*?)" type="hidden"\/>/i', $form, $input);

  $var = array();

  for($i=0;$i<count($input[1]);$i++){
    $var[$input[1][$i]] = $input[2][$i];
  }
?>

C# source

Match match = Regex.Match(html, "<input name=\"(.*?)\" value=\"(.*?)\" type=\"hidden\"/>", RegexOptions.IgnoreCase );
while (match.Success)
{
    System.Console.WriteLine(" {0} {1} ", match.Value, match.Index);  
}

The php code works, but the c# code does not work. how can I fix the c# code?
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-06-12T02:59:10+00:00Added an answer on June 12, 2026 at 2:59 am

    The problem with your regular expression is you omitted the type=\"text\". The following works:

    string html =
        @"<form>
        <input type=""text"" name=""a"" value=""a1fa4"" type=""hidden""/>
        <input type=""text"" name=""b"" value=""b1fa9"" type=""hidden""/>
        <input type=""text"" name=""c"" value=""c1fd2"" type=""hidden""/>
        <input type=""text"" name=""d"" value=""d1fx1"" type=""hidden""/>
        </form>";
    
    foreach(Match match in Regex.Matches(html, 
        "<input type=\"text\" name=\"(.*?)\" value=\"(.*?)\" type=\"hidden\"/>", 
            RegexOptions.IgnoreCase))
    {
        // Group 0 is the string matched so get groups 1 and 2.
        System.Console.WriteLine("Name={0} Value={1} ", match.Groups[1].Value, 
            match.Groups[2].Value);
    }
    

    However, as L.B says, use a dedicated HTML parser instead of regular expressions because HTML is not guaranteed to be valid XML, may contain different layouts and encodings and so on.

    If you must use regular expressions, they need to be a lot more flexble. For example there may be more or different whitespace between attributes and elements.

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

Sidebar

Related Questions

Heres my simple html source <html> <head> <title> Dec2Bin </title> <script type=text/javascript> function app()
Currently I have an HTML form with a hidden field right before a text
Say I'm at the url http://mysite.com/form.html . When viewing source, I see <form method=post
I want to get HTML source of select text in div and alert that.
I saw How to hide html source & disable right click and text copy?
<script type=text/javascript language=javascript> $(function() { $(#distributor).autocomplete({ source: function(request, response) { $.ajax({ url: /Devices/autoDistributor, type:
How would I pull out the form values for the html source below and
i have an html form ,php scrip and jquery. i need a ajax code
I am trying to write a PHP script that will create an HTML form
How can I change the code below so instead of a text input type

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.