Flashcards
classes & objects / regular expressions (Day 4)
Flashcards do conjunto (29)
- 1What are the main parts of a class?-class
-classname
-object
def __init__():
def __repr__():
self - 2What is the constructor of the class object; called when an instance is created?def__init__():
- 3what part of a class represents the object itself?self
- 4What does the def __repr__ (): dor?it returns a string of how the programmer want the object to be displayed when print PRINT calls on the object
- 5What is a metacharacter?by combining metacharacters sequences in a regular expression you can craft a sophisticated expression to match very specific data in a string
- 6What are escape characters ? \( \\ \n \tUsed to turn off (escape) the special meaning of a metacharacter or confer special meaning to other characters
- 7True or False A character Class is a list of values that can match a single character. [0-9]True
- 8Regex Character Class: [0-9] =?\d
any digit character - 9Regex Character Class: [^0-9]\D
any non-digit character - 10Regex Character Class: [A-Za-Z0-9_]Any word character
\w - 11Regex Character Class: [^A-Za-Z0-9_]Any non word character
\W - 12Regex Character Class: [\t\r\n\f]Any white space Character
\s - 13Regex Character Class: [^\t\r\n\f]Any non white space area
\S - 14Regex Character Class: [0-9A-Fa-f]ASCII HEX Character Range
- 15True or False A Quantifier {} is used to indicate how many times the previous token should be repeated. NO SPACE between {}True
- 16Regex Quantifier {} shortcuts: {0,}zero or more of the previous token
* - 17Regex Quantifier {} shortcuts: {1,}One or more of the previous token
+ - 18Regex Quantifier {} shortcuts: {0,1}zero or one of the previous token
? - 19Example of a {} \d{3}Matches 3 digits in a row
- 20What is the Start and Stop Anchor used for? ^ = start $ = Stopused to match the start of a string and end of a string.
Basically the start and end of the sting must match whats in between the anchors
r "^\d{3}$" - 21This type of anchor is used to match a word boundary position such as whitespace before or after a word character. Allows a match on a whole words only\b
example
\b\ddog\b
matches if string has single digit followed by dog - 22. = ?Wildcard
- 23A dot is used to match any single character True or FalseTrue
- 24Group () are used to make a group of tokens that can be quantified as a unit, or create a list of string values to choose from. if successful each captured group is accessible by python.True
(\d{3})-(\d{3})-(\d{4})
captures group of phone numbers - 25OR |can be used in a group to create a selection of strings to choose from
- 26What are the 3 flags in REGEX?re.S
re.I
re.M - 27What are flags?A flag modifies the way a regular expression examines data.
- 28What is match()method used forused to search through a string starting at its beginning. it returns a match object if successful otherwise none s returned
matchobject = re.match(r"expression", "string", flags) - 29search() Method findall() methodFUCK
Informações
- Descrição
- FlashCards sobre classes & objects / regular expressions (Day 4), criado por jeriel.juarbe2031 em 28-08-2014.
- Criado por
- jeriel.juarbe2031
- Visualizações
- 13
- Avaliação