re.match(pattern,text) -> searches for the pattern only in the beginning of the string.
This file, covers the following topcis -
- Difference between raw string and python string.
- match method in re library
- how to write unit test
re.search(pattern,text) -> returns the first match in the text. re.findall(pattern,text) -> returns a list of all the matches. re.findieter(pattern,text) -> returns an iterator
This file,covers the following topic -
- search method in re, and how its different from match
- findall mehod
- finditer, and how it covers up the possible disadvantage of findall
- groups, and how we can name the groups.
re.sub(pattern, replacement pattern / function, text) -> returns the text where the string matching the pattern is replaced by a string given by the replacement pattern / function
This file covers the following topic-
- using re.sub with a pattern
- using re.sub with a user defined function
- re.split
This file covers the following topic -
- searching for a single character, and making the search case insensitive.
- Using range of characters to search, eg, [a-z]
- Using wildcard .(dot) to find all characters also, how can we search if we want to search a dot.
- Finding newlines, using hexadeciaml code and unicode.
This file covers the following topic -
- searching for a given word (using word boundary)
- searching for a word at beginning of a string ( by using '^' )
- enabling multiline mode and searching for a word at the beginning of all lines.
- searching for a word at the end of a string (by using '$' )
- enabling multiline mode and searching for a word at the end of all lines
This file covers the following topic -
- searching for word digits using \d character class
- searching digits in other scripts than english
- using negation \D
- seaching for alpa numeric characters using \w
- using \w in devnagari script
- using the negation of \w, which is \W
This file covers the following topics -
- Searching words with custom matches like -
- aplhabet followed by a digit
- alphabet followed by zero or more digit
- alphabet followrd by one or more digit
- two alphabets followed by one or more digits