javascript replace all with case insensitive and keeping correct case in original string

后端 未结 1 1542
情话喂你
情话喂你 2020-12-10 03:38

My problem is i want to do something like this:

Javascript vaja => Javascript vaja i.e i have a query string(ja

相关标签:
1条回答
  • 2020-12-10 04:22

    Simply use a capturing group:

    "Javascript vaja".replace(/(ja)/gi, '<b>$1</b>');
    

    See this working demo.

    Edit: Read more about capturing groups here.

    0 讨论(0)
提交回复
热议问题