回答編集履歴
3
調整
test
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
var str="aaa @ah @a aaa";;
|
20
20
|
|
21
|
-
str=str.replace(/(@)(
|
21
|
+
str=str.replace(/(@)(\S+?)/g,"change$1$2 $2");
|
22
22
|
|
23
23
|
console.log(str);
|
24
24
|
|
2
調整
test
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
var str="aaa @ah @a aaa";;
|
20
20
|
|
21
|
-
str=str.replace(/(@)(.+?)(?=
|
21
|
+
str=str.replace(/(@)(.+?)(?=\s)/g,"change$1$2 $2");
|
22
22
|
|
23
23
|
console.log(str);
|
24
24
|
|
1
調整
test
CHANGED
@@ -11,3 +11,15 @@
|
|
11
11
|
console.log(str);
|
12
12
|
|
13
13
|
```
|
14
|
+
|
15
|
+
"aaa @ah @a aaa"を"aaa change@ah ah change@a a aaa"に変更したい場合はこう
|
16
|
+
|
17
|
+
```javascript
|
18
|
+
|
19
|
+
var str="aaa @ah @a aaa";;
|
20
|
+
|
21
|
+
str=str.replace(/(@)(.+?)(?= |$)/g,"change$1$2 $2");
|
22
|
+
|
23
|
+
console.log(str);
|
24
|
+
|
25
|
+
```
|