Asp tutorial. net new regex the title method in regular expression
Using system. text. regularexpressions; // regular
String strhtml = "</ul> <div id =" photo-tags ">
Regex re = new regex ("(? <= <Li> <a href = '/user/[^>] */tags/[^>] *> ).*? (? = </A> </li> )");
If (re. ismatch (strhtml ))
{
Matchcollection mc = re. matches (strhtml );
Foreach (match ma in mc)
{
For (int I = 0; I <ma. groups tutorial. count; I ++)
{
Textbox2.text + = ma. groups [I]. value + "";
}
Textbox2.text + = "n ";
}
}
Else
{
Textbox2.text = "no ";
}
Result:
Belgium
Belgien
Urlaub
Holidays
Vakanties
Centerparcs
10 000 000
The following example uses a regular expression to check repeated words in a string. Regular expression B (? <Word> w +) s + (k <word>) B can be interpreted as follows.
Mode
Description
B
Match from the word boundary.
(? <Word> w +)
Match one or more word characters (up to the word boundary ). Name the capture group word.
S +
Matches one or more white spaces.
(K <word>)
Match the capture group named word.
B
Match the word boundary.
If the current system culture is en-us, the resulting regular expression will be ^ w * [+-]? W? $? W? (D *.? D {2 }?) {1} $. This regular expression can be explained as shown in the following table.
Mode
Description
^
Start at the beginning of the string.
W *
Matches zero or multiple white spaces.
[+-]?
Matches zero or one of the positive or negative signs.
W?
Matches zero or one blank character.
$?
Matches zero or one of the dollar signs.
W?
Matches zero or one blank character.
D *
Matches zero or multiple decimal numbers.
.?
Matches zero or one decimal point.
D {2 }?
Matches two decimal digits zero times or once.
(D *.? D {2 }?) {1}
Match at least once the decimal point is used to separate integers and decimals.
$
Matching the end of a string