Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the. * in a regular expression? Or. * +

2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly talks about "what is the regular expression. *? or. * +", interested friends might as well take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what is the regular expression. *? or. * +"!

Brief introduction of regular expression

Regular expression, also known as regular expression. (English: Regular Expression, often abbreviated as regex, regexp or RE in code), a concept in computer science. Regular expressions are often used to retrieve and replace text that conforms to a certain pattern (rule).

Many programming languages support string manipulation using regular expressions. For example, a powerful regular expression engine is built into Perl. The concept of regular expressions was first popularized by tools in Unix, such as sed and grep. Regular expressions are usually abbreviated to "regex". The singular has regexp and regex, and the plural has regexps, regexes, and regexen.

This article focuses on. * in regular expressions. Or. * +, the details are as follows:

Recently to do a tool to extract the special content of text, always can not write regular expressions, often encounter. *? Or. * + these symbols, look them up online and finally know what they mean. Record the results of the online explanation:

One more in the back? Indicates lazy mode.

Must be used after * or +

Such as:

If regular matching is used for content non-lazy pattern matching in src

Src= ". *"

The matching result is: src= "test.jpg" width= "60px" height= "80px"

It means from = "match back to the end of the match."

Laziness pattern is regular:

Src= ". *?"

Result: src= test.jpg

Because the match ends once when it reaches the first match. It won't continue to match backwards. Because he's lazy.

. Represents any character except\ n

* indicates match 0-infinity

+ means match 1-infinity

Remove the parenthesis instance

Public class Test {public static void main (String [] args) {String s = "img=32,34) http://www.sds.com/jpg(/img) picture (img=32,34) http://www.sds.com/jpg(/img)"; System.out.println (s.replaceAll ("\\ [. +?\] ","));}}

Results:

Picture http://www.sds.com/jpg Picture http://www.sds.com/jpg

Summary

At this point, I believe you have a deeper understanding of "what is the regular expression. * or. * +", you might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report