You can use JavaScript's Array filter()
method along with Regular Expressions to exclude listings that contain the words "price by negotiation" or "auction". Here's an example:
index.tsx346 chars13 lines
Output:
index.tsx66 chars2 lines
In the example above, we create an array called listings
that contains the various listings on the real estate website. We define a Regular Expression excludedWords
that matches the words "price by negotiation" or "auction" in a case-insensitive manner.
Using the filter()
method, we iterate over each listing and keep only the ones that do not match the excludedWords
Regular Expression. The resulting filtered array is stored in filteredListings
.
Finally, we log the filteredListings
array to the console, which contains only the listings that do not contain the excluded words.
Note: This solution assumes that the "listings" variable is an array of strings representing the properties on the real estate website. Modify it according to your specific use case if needed.
gistlibby LogSnag