回答編集履歴

2

否定先読み/後読みに変更

2018/01/17 14:42

投稿

think49
think49

スコア18162

test CHANGED
@@ -22,9 +22,17 @@
22
22
 
23
23
  ```plain
24
24
 
25
- (?<=[^a-zA-Z\d])[A-Z]{2}(?=[^a-zA-Z\d])
25
+ (?<![a-zA-Z\d])[A-Z]{2}(?![a-zA-Z\d])
26
26
 
27
27
  ```
28
+
29
+
30
+
31
+ **(2018/01/17 23:42追記)**
32
+
33
+
34
+
35
+ 肯定先読み/後読みでは文字列の先端/終端にマッチしなかったので、否定先読み/後読みに変更しました。
28
36
 
29
37
 
30
38
 
@@ -40,7 +48,7 @@
40
48
 
41
49
  ```plain
42
50
 
43
- (?<=[^a-zA-Z0-9])[A-Z]{2}(?=[^a-zA-Z0-9])
51
+ (?<![a-zA-Z0-9])[A-Z]{2}(?![a-zA-Z0-9])
44
52
 
45
53
  ```
46
54
 

1

markdown修正

2018/01/17 14:42

投稿

think49
think49

スコア18162

test CHANGED
@@ -4,7 +4,9 @@
4
4
 
5
5
  どのレベルの「単語」を求めているのか不明ですが、Pythonの単語は "alphanumeric characters" のようなので、それに倣うと仮定して、
6
6
 
7
+
8
+
7
- https://docs.python.org/3/howto/regex.html
9
+ - [More Pattern Power - Python 3.6.4 documentation](https://docs.python.org/3/howto/regex.html#more-pattern-power)
8
10
 
9
11
 
10
12