Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use regular expressions in perl language

Shulou Source: shulou.com Published: 2022-06-01 13:03:15 10月04日 Update

This article is about how to use regular expressions in the perl language. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.

A regular expression describes a pattern of string matching, which can be used to check whether a string contains a certain substring, replace a matching substring, or extract a substring from a string that meets a certain condition. Perl language regular expression function is not...

A regular expression describes a pattern of string matching, which can be used to check whether a string contains a certain substring, replace a matching substring, or extract a substring from a string that meets a certain condition.

Perl language regular expressions are very powerful, basically the most powerful in common languages, and many languages refer to Perl regular expressions when designing regular expression support.

Perl has three forms of regular expressions: matching, substitution, and transformation:

Match: m//(also abbreviated as//, omitting m)

Replace: s///

Conversion: tr///

These three forms are generally and =~ or!~ Use together,=~ means match,!~ indicates a mismatch.

Pattern matching has some common modifiers:

i Ignore case in mode

g Global match

Regular expression rules. Matches all characters except newline * Matches the x string zero or more times, but matches the fewest possible times? Matches 0 or 1 x string.* Match any character 0 or more times [] Matches characters [^] within [] Match does not match characters in []^ Matches the character at the beginning of the character $ Matches characters at the end of characters\d Matches a numeric character, same syntax as [0-9]\D Matches a non-numeric character\w Match letters or numbers\W Match non-English letters or numbers\s Spaces, same syntax as [\n\t\r\f]\S Non-blank thanks for reading! About "how to use regular expressions in perl language" this article is shared here, I hope the above content can be of some help to everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!

Tags: Character regular expression language string number pattern commonly used three forms content function letter more condition seed space article grammar English reference Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia vpn MySQL MariaDB Docker