regex - JavaScript to remove whatever is after the tld and before the whitespace -
i have bunch of functions filtering page down domains attached email addresses. it's working great except 1 small thing, of links coming out this:
example.com
example.org.
example.org>.
example.com"
example.com".
example.com).
example.com(comment)"
dept.example.com
example.org
example.com.
i want figure out 1 last filter (regex or not) remove after tld. of these items in array.
edit
the function i'm using:
function filterbydomain(array) { var regex = new regexp("([^.\n]+\.[a-z]{2,6}\b)", 'gi'); return array.filter(function(text){ return regex.test(text); }); }
you can use regex match tld each case:
/^[^.\n]+\.[a-z]{2,63}$/gim you validation function can be:
function filterbydomain(array) { var regex = /^[^.\n]+\.[a-z]{2,63}$/gim; return array.filter(function(text){ return regex.test(text); }); }
Comments
Post a Comment