質問編集履歴

1

質問変更

2018/02/28 09:54

投稿

Sfidante
Sfidante

スコア90

test CHANGED
File without changes
test CHANGED
@@ -30,7 +30,7 @@
30
30
 
31
31
 
32
32
 
33
- 現状は`sample.com`という文字列があれば、そのテキスト中の全体を対象にリンク化してしまいます。
33
+ 現状はテキスト中のhttpやhttpsで始まる文字列を対象にリンク化してしまいます。
34
34
 
35
35
  ```jQuery
36
36
 
@@ -38,11 +38,7 @@
38
38
 
39
39
  //http、httpsなどで始まる文字列を正規表現でリンクに置換する
40
40
 
41
- if($(this).html().match(/sample.com/)){
42
-
43
- $(this).html( $(this).html().replace(/((http|https)://[\w?=&./-;#~%-]+(?![\w\s?&./;#~%"=-]*>))/g, '<a href="$1">$1</a> ') );
41
+ $(this).html( $(this).html().replace(/((http|https)://[\w?=&./-;#~%-]+(?![\w\s?&./;#~%"=-]*>))/g, '<a href="$1">$1</a> ') );
44
-
45
- }
46
42
 
47
43
  });
48
44