search sub string


Topic: search sub string

Mbanolas asked 3 years ago

In the example provided the searh "wi du" the result is Mace Windu because each word matches a sub string of the nameI would like to search results that the names match every individual word, that means matches"wi" or "du"

**Du*_d Bolt

Luminara Un_*du**li

Mace *_Wi_*n**du***_

Wi_*lhuff Tarkin

Any idea to do it?Thanks.

https://mdbootstrap.com/snippets/standard/miguel_angel_banolas/3663656#js-tab-view


Michał Duszak staff answered 3 years ago

You have to provide parameter in the url you fetch

 const url = `https://swapi.py4e.com/api/people/?search=${encodeURI(query)}`;

You could modify the query before passing it to the url constant, for example with regular expression https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: MDB5 3.10.2
  • Device: Mac
  • Browser: Chrome
  • OS: MacOS
  • Provided sample code: No
  • Provided link: Yes