質問編集履歴
2
テンプレートの使い方も間違いっていた。
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,17 +18,19 @@
|
|
18
18
|
|
19
19
|
for in の所からわかりません。
|
20
20
|
|
21
|
-
参考コード
|
21
|
+
###参考コード
|
22
22
|
|
23
|
-
|
23
|
+
let regex = try! NSRegularExpression(pattern: "([^\"]*)", options: [])
|
24
24
|
|
25
|
-
if let match = regex.firstMatch(in: imageHTML, options: [], range: NSRange(0..<imageHTML.utf16.count)) {
|
25
|
+
if let match = regex.firstMatch(in: imageHTML, options: [], range: NSRange(0..<imageHTML.utf16.count)) {
|
26
26
|
|
27
27
|
###該当のソースコード
|
28
28
|
|
29
29
|
Swift3
|
30
30
|
|
31
|
+
```
|
32
|
+
|
31
|
-
|
33
|
+
import Foundation
|
32
34
|
|
33
35
|
|
34
36
|
|
@@ -42,13 +44,13 @@
|
|
42
44
|
|
43
45
|
let nsString = text as NSString
|
44
46
|
|
45
|
-
let results = regex.firstMatch(in: text, options: [], range: NSRange(
|
47
|
+
let results = regex.firstMatch(in: text, options: [], range: NSRange(0..<text.utf16.count))
|
46
48
|
|
47
49
|
var match = String()
|
48
50
|
|
49
51
|
for result in results {
|
50
52
|
|
51
|
-
|
53
|
+
let regex = (text as NSString).substring(with: match.rangeAt(1))
|
52
54
|
|
53
55
|
}
|
54
56
|
|
@@ -68,7 +70,7 @@
|
|
68
70
|
|
69
71
|
}
|
70
72
|
|
71
|
-
|
73
|
+
```
|
72
74
|
|
73
75
|
|
74
76
|
|
1
質問の意味が伝わらなかった。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
###前提・実現したいこと
|
2
|
+
|
3
|
+
参考コードを何度もコピーすれば動くのですが、
|
4
|
+
|
5
|
+
extensionを使って呼び出せるようにしたいです。
|
2
6
|
|
3
7
|
正規表現で最初にマッチするコードをextension
|
4
8
|
|
5
|
-
で使いた
|
9
|
+
で使いたのですが、シンタックスがわかりません。
|
10
|
+
|
11
|
+
専門用語もまだ全然わからない初心者ですが
|
6
12
|
|
7
13
|
よろしくお願いします。
|
8
14
|
|
@@ -14,17 +20,15 @@
|
|
14
20
|
|
15
21
|
参考コード
|
16
22
|
|
17
|
-
let regex = try! NSRegularExpression(pattern: "([^\"]*)", options: [])
|
23
|
+
``` let regex = try! NSRegularExpression(pattern: "([^\"]*)", options: [])
|
18
24
|
|
19
|
-
if let match = regex.firstMatch(in: imageHTML, options: [], range: NSRange(0..<imageHTML.utf16.count)) {
|
25
|
+
if let match = regex.firstMatch(in: imageHTML, options: [], range: NSRange(0..<imageHTML.utf16.count)) { ```
|
20
|
-
|
21
|
-
|
22
26
|
|
23
27
|
###該当のソースコード
|
24
28
|
|
25
29
|
Swift3
|
26
30
|
|
27
|
-
import Foundation
|
31
|
+
```import Foundation
|
28
32
|
|
29
33
|
|
30
34
|
|
@@ -64,7 +68,7 @@
|
|
64
68
|
|
65
69
|
}
|
66
70
|
|
67
|
-
|
71
|
+
```
|
68
72
|
|
69
73
|
|
70
74
|
|