回答編集履歴

2

もんだいがあったから

2022/03/26 06:32

投稿

sigurupo
sigurupo

スコア137

test CHANGED
@@ -1,9 +1,9 @@
1
1
  ```javascript
2
2
  const paragraph = 'あい**うえお**かきくけこ';
3
- const regex = /(\*\*)[^\*]+(\*\*)/g;
3
+ const regex = /\*\*([^\*]+)\*\*/g;
4
- const markUps = paragraph.matchAll(regex);
4
+ const found = paragraph.replaceAll(regex, "<em>$1</em>");
5
- for (const m of markUps) {
5
+
6
- console.log(m);
6
+ console.log(found);
7
7
  }
8
8
  ```
9
9
  生のテキストからhtmlの<>を抜き出す感じで作りました。

1

エンター間違って押しちゃった

2022/03/26 06:23

投稿

sigurupo
sigurupo

スコア137

test CHANGED
@@ -1,7 +1,9 @@
1
1
  ```javascript
2
+ const paragraph = 'あい**うえお**かきくけこ';
2
3
  const regex = /(\*\*)[^\*]+(\*\*)/g;
3
4
  const markUps = paragraph.matchAll(regex);
4
5
  for (const m of markUps) {
5
-
6
+ console.log(m);
6
7
  }
7
8
  ```
9
+ 生のテキストからhtmlの<>を抜き出す感じで作りました。