regex - How to add a TLD check to a RegExp? -


i'm using regexp below find links in string. need extend check domain tlds (.com, travel, .name, etc).

var str = "check example.com or www.example.com or http://example.com or https://example.com or www.example.travel";  var filter:regexp = /((https?:\/\/|www\.| |\*)[äöüa-z0-9\-\:\/]{1,}+\.[\*\!\'\(\)\;\:\@\&\=\$\,\?\#\%\[\]\~\-\+\_äöüa-z0-9\/\.]{2,}+)/gi  var matches = str.match(filter)  if (matches !== null) { trace("found: " + matches); } else { trace("nothing found"); } 

i think needs [.com|.travel|.name] how implement it?

i think it's lot easier in 2 steps.

  1. find links @ moment.
  2. from matched strings, isolate domain separate pattern (a dot followed letters) , check if results of match (if there any) in tld list. (indexof() example, depending on list have, or use result pattern match list))

Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

android - MPAndroidChart - How to add Annotations or images to the chart -