Got more questions? Find advice on: ASP | SQL | XML | Windows
Welcome to RegexAdvice Sign in | Join | Help

RegEx for parsing ID values out of .aspx lines

  •  12-17-2009, 10:52 PM

    RegEx for parsing ID values out of .aspx lines

    I have a need within an ASP.NET C# application to go through the .aspx files of my solution and pull out the
    IDs of certain controls within the forms.  I already have code in place to bring back all the files and stream each file line by line.
    I want to use RegEx for two purposes. 

    1) To determine if the line contains any of the pre-determined control prefixes (e.g. "txt", "rdb", "ddl" etc.)
    and if so
    2) grab the value (between double quotes) of the ID attribute. 

    A typical line that would pass the determination and that I would want to grab the value in the ID attribute looks like this:

    <asp:TextBox ID="txtMyControlName" runat="server" Width="196px" MaxLength="150"></asp:TextBox>

    In this case, the logic would have determined that this line is to be processed because it contains one of the desired control prefixes - "txt".
    Next I would want to use RegEx to grab "txtMyControlName" from the ID attribute.

    Thanks in advance for any help you can provide!

    -- dwadek

     

View Complete Thread