String.trim doesn't work

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
1 Like