我正在做一个搜索功能,我想突出显示匹配的模式。所以,无论哪种情况,我都必须分别在字符串中添加和附加所有<$>
模式</$>
。
highlight("RajkumarrAjkumarRAjkumaraj", "Ra")
# should return "<$>Ra</$>jkumar<$>rA</$>jkumar<$>RA</$>jkuma<$>ra</$>j"
highlight("RajkumarrAjkumarRAjkumaraj", "ra")
# should return "<$>Ra</$>jkumar<$>rA</$>jkumar<$>RA</$>jkuma<$>ra</$>j"
highlight("RajkumarrAjkumarRAjkumaraj", "rA")
# should return "<$>Ra</$>jkumar<$>rA</$>jkumar<$>RA</$>jkuma<$>ra</$>j"
highlight("RajkumarrAjkumarRAjkumaraj", "RA")
# should return "<$>Ra</$>jkumar<$>rA</$>jkumar<$>RA</$>jkuma<$>ra</$>j"