Цитата:
|
[quote=Gozar]зы: ты экранируешь точку в символьном классе:
Цитата:
Цитата:
|
Цитата:
Цитата:
|
вот для примера есть гугловская ссылка:
мой: var a = 'http://translate.google.ru/?js=n&prev=_t&hl=ru&ie=UTF-8&layout=2&eotf=1&sl=en&tl=ru&text=Possibly+another+solution+would+be+to+have+the+description+text+hidden+by+default+and+only+shows+when+the+title+is+focused%2Fhovered+over.%0D%0A%0D%0A+Here%27s+an+example%3A+http%3A%2F%2Fwww.1true.co.uk%2Ffastscroll.html&file=#en|ru|Mistletoe'.match( /(?:^|[\s]+)((http(s)?:\/\/)|(www\.))([^\.]+)\.([^\s]+)/i );alert(a); вот как примет ее твоя рега, в ней же и точки и куча борохла: var a = 'http://translate.google.ru/?js=n&prev=_t&hl=ru&ie=UTF-8&layout=2&eotf=1&sl=en&tl=ru&text=Possibly+another+solution+would+be+to+have+the+description+text+hidden+by+default+and+only+shows+when+the+title+is+focused%2Fhovered+over.%0D%0A%0D%0A+Here%27s+an+example%3A+http%3A%2F%2Fwww.1true.co.uk%2Ffastscroll.html&file=#en|ru|Mistletoe'.match(/(http(s)?:\/\/)?(www\.)?([-.a-z0-9]+)\.(ru|com|net){1}((\/)+[-$_.,+=:;/?@&#%a-z0-9]+)?(\/|\b)/ig);alert(a); |
Цитата:
|
Цитата:
var a='http://translate.google.ru/?js=n&prev=_t&hl=ru&ie=UTF-8&layout=2&eotf=1&sl=en&tl=ru&text=Possibly+another+solution+would+be+to+have+the+description+text+hidden+by+default+and+only+shows+when+the+title+is+focused%2Fhovered+over.%0D%0A%0D%0A+Here%27s+an+example%3A+http%3A%2F%2Fwww.1true.co.uk%2Ffastscroll.html&file=#en|ru|Mistletoe,'.match(/(http(s)?:\/\/)?(www\.)?([-.a-z0-9]+)\.(ru|com|net){1}((\/)+[-$_.,+=:;/|?@&#%a-z0-9]+)?(\/|\b)/ig); alert(a); |
Оговорюсь, что я не ставлю цель доказать что моя рега лучше или хуже. Только сравнительные характеристики, виды урлов и их контекст и выбор наиболее оптимального варианта.
|
Цитата:
var a = 'http://translate.google.ru/?js=n&prev=_t&hl=ru&ie=UTF-8&layout=2&eotf=1&sl=en&tl=ru&text=Possibly+another+solution+would+be+to+have+the+description+text+hidden+by+default+and+only+shows+when+the+title+is+focused%2Fhovered+over.%0D%0A%0D%0A+Here%27s+an+example%3A+http%3A%2F%2Fwww.1true.co.uk%2Ffastscroll.html&file=#en|ru|Mistletoe,'. match( /(?:^|[\s]+)((http(s)?:\/\/)|(www\.))([^\.]+)\.(?:[^\s,]+)/ig ); alert(a); |
Цитата:
|
Цитата:
|
Часовой пояс GMT +3, время: 02:34. |