# String.trim doesn't work

**URL:** <https://forum.xojo.com/t/string-trim-doesnt-work/73854>\
**Category:** General\
**Created:** [December 28, 2022, 10:13am UTC](https://forum.xojo.com/t/string-trim-doesnt-work/73854 "2022-12-28T10:13:43Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![Rick\_Araujo](https://forum.xojo.com/user_avatar/forum.xojo.com/rick_araujo/32/251_2.png) [@Rick\_Araujo](https://forum.xojo.com/u/Rick_Araujo)\
**Post date:** [December 28, 2022, 2:17pm UTC](https://forum.xojo.com/t/string-trim-doesnt-work/73854/11 "2022-12-28T14:17:47Z")

</div>

```auto
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

```

---

_[View the full topic](https://forum.xojo.com/t/string-trim-doesnt-work/73854)._
