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 are the basic grammars commonly used in regular expressions

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

Share

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

This article mainly introduces what are the basic grammars commonly used in regular expressions, which have a certain reference value. Interested friends can refer to them. I hope you will gain a lot after reading this article.

Java regular expressions provide a rich class library, which greatly simplifies the process. The following is a list of common basic grammars:

* +? ^ $[] () | /\ d\ D\ w\ W {} {n} {njue m}, etc.

Note that it is the "|" or symbol. It can match individual characters and strings. For example, t [aeio] n only matches tan,ten,tin,ton. However, toon does not match, because only a single character can be matched in square brackets, and to match toon, you can use t (a | e | I | o | oo) n to achieve toon.

Regular expressions are a skilled process, and there is nothing too abstract. In fact, learning software (do not like the word "programming") and other industries are the same, one of the hard indicators of programmers is the amount of code. The greater the amount of code, the more familiar (or mastered or proficient) the implementation process. Experience is not learned, just as language cannot be learned. That depends on the accumulation of a quantity. Familiarity makes perfect (the ancients are really good, they already knew this truth), the premise of innovation is to achieve a very skilled degree of something. I would like to share with my friends.

(2) String's support for regular expressions:. Regular (regex) matches regular expressions in parentheses

.split (regex) splits the string into an array of characters. Of course, the return value is a character array.

Replace (old String,new String) replaces the old string with the new one. It is important to note that the original string of the replacement process is unchanged, but a string is re-new.

Such as: String str= "abcde"

String str2=str.replace ("bc", "ff"); / / replace "bc" in str with "ff"

System.out.println (str); / / the output str value at this time is the same as the value at the beginning of initialization

The value of System.out.println (str2) / / str2 becomes the "affde" you want.

.replaceAll (regex,String) is similar to replace.

Thank you for reading this article carefully. I hope the article "what are the basic grammars commonly used in regular expressions" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support 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

Internet Technology

Wechat

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

12
Report