Asp.net new Regex the title method in regular expression

Source: Internet
Author: User
Tags regular expression

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
 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.