回答編集履歴

1

2022/11/09 05:21

投稿

melian
melian

スコア19771

test CHANGED
@@ -1,9 +1,8 @@
1
- [regex · PyPI](https://pypi.org/project/regex/) モジュールの `subf()` メソッドを使う場合です。
2
1
  ```python
3
- import regex
2
+ import re
4
3
 
5
4
  def vowel_one(text):
6
- text = regex.subf(r'([aeiou])(?i)|(.)', lambda m: '1' if m[1] else '0', text)
5
+ text = re.sub(r'(?i)([aeiou])|(.)', lambda m: '1' if m[1] else '0', text)
7
6
  return text
8
7
 
9
8
  if __name__ == '__main__':
@@ -29,4 +28,3 @@
29
28
  output: 0100100010000
30
29
  expected: 0100100010000
31
30
  ```
32
-