質問編集履歴
1
質問変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -14,13 +14,11 @@
|
|
14
14
|
|
15
15
|
それをjQuery(もしくはJavaScript)で行いたいです。
|
16
16
|
|
17
|
-
現状は
|
17
|
+
現状はテキスト中のhttpやhttpsで始まる文字列を対象にリンク化してしまいます。
|
18
18
|
```jQuery
|
19
19
|
$(".text_of_link").each(function(){
|
20
20
|
//http、httpsなどで始まる文字列を正規表現でリンクに置換する
|
21
|
-
if($(this).html().match(/sample.com/)){
|
22
|
-
|
21
|
+
$(this).html( $(this).html().replace(/((http|https)://[\w?=&./-;#~%-]+(?![\w\s?&./;#~%"=-]*>))/g, '<a href="$1">$1</a> ') );
|
23
|
-
}
|
24
22
|
});
|
25
23
|
```
|
26
24
|
|