File: err_170.py

package info (click to toggle)
python-refurb 1.27.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,700 kB
  • sloc: python: 9,468; makefile: 40; sh: 6
file content (41 lines) | stat: -rw-r--r-- 1,520 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import re
from re import search

PATTERN = re.compile("hello( world)?")

# these should match

_ = re.search(PATTERN, "hello world")
_ = re.match(PATTERN, "hello world")
_ = re.fullmatch(PATTERN, "hello world")
_ = re.split(PATTERN, "hello world")
_ = re.split(PATTERN, "hello world", 1)
_ = re.split(PATTERN, "hello world", maxsplit=1)
_ = re.findall(PATTERN, "hello world")
_ = re.finditer(PATTERN, "hello world")
_ = re.sub(PATTERN, "hello world", "goodbye world")
_ = re.sub(PATTERN, "hello world", "goodbye world", 1)
_ = re.sub(PATTERN, "hello world", "goodbye world", count=1)
_ = re.subn(PATTERN, "hello world", "goodbye world")
_ = re.subn(PATTERN, "hello world", "goodbye world", count=1)

_ = search(PATTERN, "hello world")


# these should not

_ = re.search(PATTERN, "hello world", re.IGNORECASE)
_ = re.match(PATTERN, "hello world", re.IGNORECASE)
_ = re.fullmatch(PATTERN, "hello world", re.IGNORECASE)
_ = re.split(PATTERN, "hello world", flags=re.IGNORECASE)
_ = re.split(PATTERN, "hello world", 1, flags=re.IGNORECASE)
_ = re.findall(PATTERN, "hello world", re.IGNORECASE)
_ = re.finditer(PATTERN, "hello world", re.IGNORECASE)
_ = re.sub(PATTERN, "hello world", "goodbye world", flags=re.IGNORECASE)
_ = re.sub(PATTERN, "hello world", "goodbye world", 1, re.IGNORECASE)
_ = re.subn(PATTERN, "hello world", "goodbye world", flags=re.IGNORECASE)
_ = re.subn(PATTERN, "hello world", "goodbye world", 1, flags=re.IGNORECASE)

_ = PATTERN.search("hello world")

_ = re.search("hello world", "hello world")