Get the App
SLTechnology News&Howtos  ›  Servers  › 

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

Shulou Source: shulou.com Published: 2022-05-31 16:09:13 10月02日 Update

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!

Tags: Regular expression meaning laziness pattern article content result picture character tool concept rule support medium powerful special code value interest Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Technology Docker Apple OPPO Reno