In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces how to use regular expressions to obtain Chinese characters in strings. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
Requirement: only get the "executor form for Editing initiating status" in attr. The path C:\ fakepath\ is not fixed, but can be C:\ fakepath\ hhh\ hhhh\
Resolve:
Var attr = C:\ fakepath\ Edit the executor form of the initiating state .png attr = title.split (".") [0]; / / intercept-- > "C:\ fakepath\ edit the executor form of the initiating state" var reg = new RegExp ('[\ u4e00 -\ u9fa5] + $','g'); / / define the rule: intercept the part ending in Chinese characters, + represents one or more Chinese characters attr = reg.exec (attr) / / intercept to-- > Edit the executor form alert (attr) of the initiating status
Supplement the regular basic syntax (source network):
1. Non-printing character
The character meaning\ cx matches the control character indicated by x. For example,\ cM matches a Control-M or carriage return. The value of x must be one of Amurz or aMuz. Otherwise, c is treated as a literal'c 'character. \ f matches a feed character. Equivalent to\ x0c and\ cL. \ nmatches a newline character. Equivalent to\ x0a and\ cJ. \ r matches a carriage return. Equivalent to\ x0d and\ cM. \ s matches any white space characters, including spaces, tabs, page breaks, and so on. Equivalent to [\ f\ n\ r\ t\ v]. \ s matches any non-white space character. Equivalent to [^\ f\ n\ r\ t\ v]. \ t matches a tab. Equivalent to\ x09 and\ cI. \ v matches a vertical tab. Equivalent to\ x0b and\ cK.
two。 Special character
The so-called special characters are some characters with special meaning, such as the * in "* .txt" mentioned above, which simply means the meaning of any string. If you want to find a file with a * in the file name, you need to escape *, that is, add a\ to it. Ls\ * .txt. Regular expressions have the following special characters.
The special character indicates that $matches the end of the input string. If the Multiline property of the RegExp object is set, $also matches'\ n'or'\ r'. To match the $character itself, use\ $. () marks the start and end positions of a subexpression. Subexpressions can be obtained for later use. To match these characters, use\ (and\). * matches the previous subexpression zero or more times. To match the * character, use\ *. + matches the previous subexpression one or more times. To match the + character, use\ +. . Matches any single character except the newline character\ n. To match., use\. [marks the beginning of a bracketed expression. To match [, use\ [. ? Matches the previous subexpression zero or once, or indicates a non-greedy qualifier. To play Standard PvP match? Characters, please use\? \ Mark the next character as either a special character, a literal character, a backward reference, or an octal escape character. For example,'n' matches the character'n'. \ n' matches the newline character. The sequence'\ 'matches "\", while'\ ('matches "(". ^ matches the start position of the input string unless used in a square bracket expression, where it indicates that the character collection is not accepted. To match the ^ character itself, use\ ^. {Mark the beginning of the qualifier expression. To match {, use\ {. | indicates a choice between the two items. To match |, use\ |.
You construct regular expressions in the same way as you create mathematical expressions. That is, a variety of metacharacters and operators are used to combine small expressions to create larger expressions.
The components of a regular expression can be a single character, a character collection, a character range, a choice between characters, or any combination of all these components.
3. Qualifier
Qualifiers are used to specify how many times a given component of a regular expression must appear to satisfy a match. Is there * or + or? Or {n} or {n,} or {n ~ m}.
*, + and? Qualifiers are greedy because they match as many words as possible, only adding one after them. Non-greedy or minimal matching can be achieved.
The qualifiers for regular expressions are:
The character description * matches the previous subexpression zero or more times. For example, zo* can match "z" and "zoo". * is equivalent to {0,}. + matches the previous subexpression one or more times. For example, 'zo+' can match "zo" and "zoo", but not "z". + is equivalent to {1,}. ? Matches the previous subexpression zero or once. For example, "do (es)?" Can match "do" in "do" or "does". ? It is equivalent to {0jue 1}. {n} n is a non-negative integer. Match the determined n times. For example,'o {2} 'does not match the' o'in 'Bob', but does match the two o in 'food'. {n,} n is a non-negative integer. Match at least n times. For example,'o {2,} 'does not match' o'in 'Bob', but does match all o in 'foooood'. O {1,}'is equivalent to 'oasis'. O {0,}'is equivalent to 'oval'. {n ·m} m} m and n are non-negative integers, where n
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.