Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

DatabindExprRegex Class

Provides a regular expression to parse an ASP.NET data-binding expression.

Namespace: System.Web.RegularExpressions
Assembly: System.Web.RegularExpressions (in system.web.regularexpressions.dll)

public class DatabindExprRegex : Regex, ISerializable
public class DatabindExprRegex extends Regex implements ISerializable
public class DatabindExprRegex extends Regex implements ISerializable
Not applicable.

The DatabindExprRegex class provides a compiled regular expression to parse an ASP.NET data-binding expression (<%#%>).

NoteNote:

The System.Web.RegularExpressions classes are meant to be used by the .NET Framework to parse ASP.NET pages and are not always practical for general applications. For example, many of these classes match only the beginning of a string.

The predefined regular expression pattern used by the DatabindExprRegex class is \G<%#(?<code>.*?)?%>. This regular expression returns a databinding expression block, including its beginning and ending tags and all of its contents. However, for a match to occur, the databinding expression block must start at the beginning of the input stream. For multiple databinding expression blocks to be found in a call to the DatabindExprRegex object's Matches method, they must be immediately contiguous to one another. That is, the %> tag that terminates the previous databinding expression must be immediately followed by the <%# tag that begins the next databinding expression, without any intervening characters.

You can retrieve all inline databinding expression blocks regardless of their position in an input string in either of two ways:

  • By instantiating a Regex object whose regular expression pattern is <%#(?<code>.*?)?%>.

  • By using the String.IndexOf overload to locate the next opening tag of a databinding expression in a string, and then using this position when calling the DatabindExprRegex object's Match method. The following example illustrates how to use this technique with the DatabindExprRegex object to extract all the databinding expression blocks in a string.

The following example demonstrates the DatabindExprRegex class. The example illustrates that a databinding expression block matches the regular expression pattern only if it is at the beginning of a string or if it immediately follows the preceding match.

System.Object
   System.Text.RegularExpressions.Regex
    System.Web.RegularExpressions.DatabindExprRegex

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft