回答編集履歴

2

xxx

2018/10/19 11:48

投稿

退会済みユーザー
test CHANGED
@@ -4,8 +4,12 @@
4
4
 
5
5
 
6
6
 
7
+ 質問に対してちょっと斜めの回答になりますが…
8
+
9
+
10
+
7
11
  ```javascript
8
12
 
9
- "<div data-url='http://www.sample.jp/'><title>サンプル</title></div>\r\n".repeat(content.match(/http://www.sample.jp//g).length)
13
+ link.repeat(content.match(/http://www.sample.jp//g).length)
10
14
 
11
15
  ```

1

xxx

2018/10/19 11:48

投稿

退会済みユーザー
test CHANGED
@@ -1,3 +1,11 @@
1
- 正規表現は複雑になり、テスト・保守がずらい気がします。
1
+ 質問文をちゃんと読めていませんでした(^^;
2
2
 
3
+ 訂正したものを記載しておきます。
4
+
5
+
6
+
7
+ ```javascript
8
+
3
- 区切り文字が"、"なのであれば、それで文字列を分割し、配列にして、<div data-...となっていなければ、そうするような処理にしたほうが良いように思えます。
9
+ "<div data-url='http://www.sample.jp/'><title>サンプル</title></div>\r\n".repeat(content.match(/http://www.sample.jp//g).length)
10
+
11
+ ```