• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2226
  • Last Modified:

C# Regex. Get value attribute from input html tag with specific id.

Been struggling with this for awhile.  I can't seem to figure out how to get a regex request to only return the value attribute of a particular <input> tag.  Any help is greatly appreciated.
0
foxygt
Asked:
foxygt
1 Solution
 
needtokenCommented:
hai foxygt

     I added a small sample try this.
System.Text.RegularExpressions.Regex objRegEx = new System.Text.RegularExpressions.Regex("<input([\\s\\S]*?) value=[\"']([\\s\\S]*?)[\"']");
            System.Text.RegularExpressions.MatchCollection objMatchs;
            
            objMatchs =  objRegEx.Matches ("<input masdtayu=jijukijdf value=\"myvalue\"") ;

            foreach (System.Text.RegularExpressions.Match  objMatch in objMatchs)
            {
                
                MessageBox.Show(objMatch.Groups[2].Value); 
            }

Open in new window

System.Text.RegularExpressions.Regex objRegEx = new System.Text.RegularExpressions.Regex("<input([\\s\\S]*?) value=[\"']([\\s\\S]*?)[\"']");
            System.Text.RegularExpressions.MatchCollection objMatchs;
            
            objMatchs =  objRegEx.Matches ("<input masdtayu=jijukijdf value=\"myvalue\"") ;

            foreach (System.Text.RegularExpressions.Match  objMatch in objMatchs)
            {
                
                MessageBox.Show(objMatch.Groups[2].Value); 
            }

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now