回答編集履歴

3

追記

2021/08/05 02:23

投稿

bsdfan
bsdfan

スコア4576

test CHANGED
@@ -19,3 +19,9 @@
19
19
  s_regex = re.compile(r"([^()]+)")
20
20
 
21
21
  ```
22
+
23
+
24
+
25
+ バックスラッシュを含む正規表現を作るときはrつきのリテラルで書く方がおすすめです。
26
+
27
+ また、strを変数名に使うのは、pythonのstr型と被るので、混乱したり、str型に変換したいときなどに困るのでやめた方がいいです。

2

修正

2021/08/05 02:23

投稿

bsdfan
bsdfan

スコア4576

test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  ```python
8
8
 
9
- s_regex = re.compile("(.+?)")
9
+ s_regex = re.compile(r"(.+?)")
10
10
 
11
11
  ```
12
12
 
@@ -16,6 +16,6 @@
16
16
 
17
17
  ```python
18
18
 
19
- s_regex = re.compile("([^()]+)")
19
+ s_regex = re.compile(r"([^()]+)")
20
20
 
21
21
  ```

1

修正

2021/08/05 02:15

投稿

bsdfan
bsdfan

スコア4576

test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  最短パタンでマッチさせる。
6
6
 
7
- ``python
7
+ ```python
8
8
 
9
9
  s_regex = re.compile("(.+?)")
10
10
 
@@ -14,7 +14,7 @@
14
14
 
15
15
  カッコを含まないパタンでマッチさせる。
16
16
 
17
- ``python
17
+ ```python
18
18
 
19
19
  s_regex = re.compile("([^()]+)")
20
20