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

In regular expressions. *? Or. * what does it mean?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces regular expressions. *? Or. * what does it mean? it has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let's take a look at it with you.

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.

The details are as follows:

Recently, I want to make a tool to extract the special content of the text. I always can't write regular expressions. Or. + these symbols, look up online, finally know what it means, and record the results of online interpretation:

One more in the back? Indicates lazy mode. Must be followed by * or +, such as:

If you match src= ". *" with regular matching src content non-lazy pattern: src= "test.jpg" width= "60px" height= "80px" means from = "match to the end of the match, lazy pattern regular: src=. *?" Result: src= "test.jpg" ends a match because the match reaches the first ". Will not continue to match backward. Because he is lazy.. Indicates any character except\ n * indicates match 0-infinity + indicates 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 ("\\ [. +?\] ",");}} Thank you for reading this article carefully, I hope the editor shares the regular expression. *? Or. * what does this article mean? "this article is helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you 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

Servers

Wechat

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

12
Report