Question: What's the **JavaScript** equivalent to this `C#` Method:

```
var x = "|f|oo||"; 
var y = x.Trim('|'); //  "f|oo"

```

C# trims the selected character only at the **beginning** and **end** of the string!

Answer: 
```
"|Howdy".replace(new RegExp("^\\|"),"");

```

*(note the double escaping. `\\` needed, to have an actually single slash in the **string**, that then leads to escaping of `|` in the **regExp**).*

*[Only few characters need regExp-Escaping.](https://stackoverflow.com/a/400316/444255), among them the pipe operator.*
To my knowledge, jQuery doesnt have a built in function the method your are asking about.
With javascript however, you can just use replace to change the content of your string:

```
x.replace(/|/i, ""));

```

This will replace all occurences of | with nothing.