Var curMeta As String = "content=""SBF borrowed $546M from Alameda to fund Robinhood"""
Var removePattern As String = "^\s*data-n-head\s*=\s*" // only at beginning and can have spaces around
Var re As New RegEx
re.SearchPattern = removePattern
re.ReplacementPattern = ""
// *** Tests ***
Var s As String = re.Replace("data-n-head="+curMeta)
If s <> curMeta Then MessageBox("Assertion 1 Failed")
s = re.Replace(" data-n-head = "+curMeta)
If s <> curMeta Then MessageBox("Assertion 2 Failed")
curMeta = "content=""SBF borrowed the string 'data-n-head=' to fund Robinhood"""
s = re.Replace("data-n-head="+curMeta)
If s <> curMeta Then MessageBox("Assertion 3 Failed")
MessageBox "If no assertion has been fired, tests were OK"
Quit
I tried the following code and it works as you expected:
Var CurMeta as String = "data-n-head="+"content=""SBF borrowed $546M from Alameda to fund Robinghood"""
Var curRemove as string = "data-n-head="
var pos as integer = CurMeta.IndexOf(curRemove)
if pos <> -1 then
Break
CurMeta = CurMeta.Trim(curRemove)
end if
Break
First break shows data-n-head= in CurMeta
Second break, is gone:
Maybe you have invisible characters and that is why Trim is not working for you?