Remove the source code line number using a regular expression,

Source: Internet
Author: User

Remove the source code line number using a regular expression,

Abstract: remove the source code line number with a regular expression, and then learn some common Regular Expression operators. Remove the row number step: first use search-replace, then use regular expression to match the row number, and then replace it with null.

The regular expression is:

^\d+\.

Note:

  

^ Indicates the starting position of the row.

  

\ D + match Digit

  

\. Match separator "."

\<\d+\>

It is used to match the line number with spaces and no delimiters in the future.

Table 1 Regular Expression Operators

Operator

Effect

.

Match any single character.

?

The previous items are optional and can be matched at most once.

*

Matches the previous project that appears zero or multiple times.

+

Match the previous project once or multiple times.

{N}

Precisely match N previous projects.

{N ,}

The previous project matches N or more times.

{N, M}

The previous project matches at least N times, but not more than M times.

-

Indicates that the range is not the first or last in the list or the end point of a range.

^

Matches an empty string at the beginning of a row, or a character that is not in the list range.

$

Matches the null string at the end of the row.

\ B

Matches empty strings on both sides of a word.

\ B

Match the provided Null string Matches the empty string provided it's not at the edge of a word.

\ <

Matches an empty string starting with any word.

\>

Matches an empty string at the end of any word.

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.