The following features are given in the Java Java.util.regex.Pattern class:
Predefined character classes
.
Any character (may or may not match the line terminator)
/d
Number: [0-9]
/d
Split it splits the string according to the given pattern, and it is quite handy to decompose the extracted fields with this operator for strings that separate different fields with tabs, colons, whitespace characters, or any symbol. As long as you
Namespaces: System.String.Split Assembly: mscorlib (mscorlib.dll) Simple example: String before = "12,50,30"; String[] After =before. Split (New char[]{', '}); The result is after[0] = 12; AFTER[1] = 50; AFTER[2] = 30; 1. Regular expressionIf the
1:strip () method,remove spaces at the beginning or end of a string
>>> a = "a b C"
>>> A.strip ()
' A B C '
2:lstrip () method,remove spaces at the beginning of a string
>>> a = "a b C"
>>> A.lstrip ()
' A B C
A string sequence is used to represent and store text, and a string in Python is an immutable object. A string is a collection of ordered characters that is used to store and represent basic textual information, a pair of single, double, or triple
Knowledge Supplement
The split method of string supports regular expressions;
The regular expression \s represents any white space character that matches + one or more occurrences.
With the above supplementary knowledge, the
1-Hierarchical inheritance2-Variable and immutable concepts3-string3.1-string is a very special class3.2-string literals vs. String objectsMethods of 3.3-string3.3.1-length ()3.3.2-concat (String)3.3.3-indexof (..)3.3.4-substring (..)3.3.5-replace3.3
1. Returns the length of the string
Copy Code code as follows:
Str.length => Integer
2. Determine if the string contains another string
Copy Code code as follows:
Str.include? Other_str => True or False
Gsub (regexp, replacement [, target])
Search target for all of the longest, leftmost, nonoverlapping matching substrings it can find and replace them with replacement. the 'G' in gsub () stands for "global," which means replace everywhere. for
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.