-1

I have a object "news" that have the property "url".

I want to use regex to filter out all the objects that have the "url" property ENDING with a specific value, in this case "news.aspx". That is, I want the conditional only to look at the end of that property, and not the whole string. Array operator "endsWidth()" has no IE11 support frankly, and thats why I'm using regex instead.

I'm trying to use Regex to filter out a specific value. Below will not filter out but instead give me all the objects where url ends with "news.aspx"

newsArticles.filter(n => /news.aspx$/.test(n.url))

I have search and tried to modify it so it instead filter out, like:

newsArticles.filter(n => ^(/?!news.aspx$/).test(n.url))

But it doesnt work.

Arte2
  • 309
  • 4
  • 19

1 Answers1

0
newsArticles.filter(n => !/news\.aspx$/.test(n.url))
ezakto
  • 3,174
  • 22
  • 27