Skip to content

Dynamic Regex to Match Words in a Sentence given in any order

Notifications You must be signed in to change notification settings

symmetriccurve/DynamicRegexx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 

Repository files navigation

A Simple utility tool to take senstense and match all words passed and return filtered senstences

const sentences = [
  "test1",
  "test1 test2",
  "test1 test2 test3",
  "test1 test2 test3 test4",
]
console.log(findAllMatches(sentences, "test1 test2"))

["test1 test2", "test1 test2 test3", "test1 test2 test3 test4"]

// Given in any order

console.log(findAllMatches(sentences, "test1 test4"))

["test1 test2 test3 test4"]

console.log(findAllMatches(sentences, "test4 test1"))

["test1 test2 test3 test4"]

Looking for a particular key in array of object

const sentences = [
  {
    sentence:" test1"
  },
  {
    sentence:" test1 test2"
  },
  {
    sentence:" test1 test2 test3"
  },
  {
    sentence:" test1 test2 test3 test4"
  }
]
console.log(findAllMatches(sentences,"test4",'sentence'))

[{ sentence:" test1 test2 test3 test4"}]

About

Dynamic Regex to Match Words in a Sentence given in any order

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published