0

hi i am developing ajax search result.I want to highlight the words and alphabets which user inputs.I use jason api for result.I use regexp but it does not work. Code is:

 var string = data;//search result
 var string2 = keyword;//user input
 var regex = new RegExp( string2, 'g' );
 var pattern=string.match(regex);

for example If user type s in input box then all S should be bold in search result.Spain,Sweden like this or much alphabets and words as user inputs

Andrew
  • 67
  • 2
  • 8

1 Answers1

0

Have you checked out https://github.com/ddsky/unibox ? Seems to do what you're asking for. Im not the author though.

shashanka n
  • 2,568
  • 1
  • 14
  • 21