Matches the regular expressions and form regular expressions of all content in the form.

Source: Internet
Author: User

Matches the regular expressions and form regular expressions of all content in the form.

The requirement is as follows:
There is now a form
Copy codeThe Code is as follows: <form action = 'mk. php'> ...... </form>
The ellipsis in the form represents the content, which has a variety of labels <>.
You want to write a regular expression to match the entire form, including the form tag, which is the content in the html file.

The first thing that comes to mind is:

Copy codeThe Code is as follows:
<Form. * </form>

In this way:
Copy codeThe Code is as follows:
<Form [^>] */form>

This is also the case:
Copy codeThe Code is as follows:
<Form. * <\/form>

As long as there are tags in the form, no content can be matched. It is inexplicable and I don't know why.

Later I consulted a regular expression expert and he told me another method:
Copy codeThe Code is as follows:
<Form [\ s \ S] * </form>

This involves the greedy mode and the non-Greedy mode.

[\ S \ S] indicates that all white spaces + non-white spaces are matched.
* It means 0 or more, and it will be stopped after it is met.

In this way, all the content in form is matched.

Note: <form [\ s \ S] * </form> is successfully verified in DW.


Match content with a regular expression

Just remove \ B. Second, I believe you will.
3rd: <form. * </form>

Help write a regular expression to extract form data. C #

Use the regular expression to retrieve the number of rows, that is, the number of rows in <table>.
<TR [^>] *> ([\ s \ S] *?) <\/TR>

The number of returned results is how many pieces of data he has, and then he uses the following regular expression to retrieve each result:
> ([^ <] *) <\/

The search result is the data you want.

Note: C # Remember to escape special characters or add the @ symbol before the string

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.