質問するログイン新規登録

質問編集履歴

2

誤字修正

2019/12/16 06:35

投稿

cray123
cray123

スコア47

title CHANGED
File without changes
body CHANGED
@@ -10,7 +10,7 @@
10
10
  ###試したこと
11
11
  ```
12
12
  func isMatch(_ string: String) -> Bool {
13
- let regex = "/(?=[0-9]{4,})(?=./)/"
13
+ let regex = "/(?=[0-9]{1,})(?=./)/"
14
14
  let text = NSPredicate(format:"SELF MATCHES %@", regex)
15
15
  let result = text.evaluate(with: string)
16
16
  return result

1

誤字修正

2019/12/16 06:35

投稿

cray123
cray123

スコア47

title CHANGED
File without changes
body CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  "1+2-3*4/5+1"
5
5
  ↑の文字列から"/"から続く文字列(次の演算子が来るまでの数値)
6
- 上の例の場合"5"を抽出したいです。
6
+ 上の例の場合"5"を抽出したいです。(ゼロ除算対策です)
7
7
 
8
8
  よろしくお願いします。
9
9