Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question[...]
var regex = new RegExp("<[^>]+?("+searchTerms[i]+").*?>|("+searchTerms[i]+")","ig");
element.innerHTML = tempinnerHTML.replace(regex,'$2');
var regex = new RegExp("<(?<![^>]+?)"+searchTerms[i]+".*?>|("+searchTerms[i]+")","ig");
The only regex engines that allow you to use a full regular expression inside lookbehind are the JGsoft engine and the .NET framework RegEx classes.
Finally, flavors like JavaScript, Ruby and Tcl do not support lookbehind at all, even though they do support lookahead.
Dim sBuffer As String With New RegExp .Global = True .IgnoreCase = True sBuffer = "handicap handicap sur handicap handicap handicap" .Pattern = "(<[^>]*?handicap.*?>|handicap)" sBuffer = .Replace(sBuffer, "{{$1}}") .Pattern = "\{\{(<[^>]*?>)\}\}" sBuffer = .Replace(sBuffer, "$1") .Pattern = "\{\{(.*?)\}\}" sBuffer = .Replace(sBuffer, "$1") MsgBox sBuffer End With
Dim sBuffer As String Dim sOut As String Dim nPos As Long Dim oMatch As Match With New RegExp .Global = True .IgnoreCase = True sBuffer = "hello handicap handicap sur handicap handicap handicap" .Pattern = "(<[^>]*?handicap.*?>|handicap)" For Each oMatch In .Execute(sBuffer) sOut = sOut & Mid$(sBuffer, nPos + 1, oMatch.FirstIndex - nPos) nPos = oMatch.FirstIndex + oMatch.Length If Left$(oMatch.Value, 1) = "<" Then sOut = sOut & oMatch.Value Else sOut = sOut & "" & oMatch.Value & "" End If Next MsgBox sOut End With
handicap, si pas suivi de 0 à n caractères