Question: If I have a string that contains this somewhere (Foo could be anything):

```
<tag>Foo</tag>

```

How would I, using SED and RegEx, replace it with this:

```
[tag]Foo[/tag]

```

My failed attempt:

```
echo "<tag>Foo</tag>" | sed "s/<tag>\(.*\)<\\/tag>/[tag]\1[\\/tag]"

```

Answer: 
Your regex is missing the terminating `/`

```
$ echo "<tag>Foo</tag>" | sed "s/<tag>\(.*\)<\\/tag>/[tag]\1[\\/tag]/"
[tag]Foo[/tag]

```
With this you can replace all types of tags and don't have to be tag specific.

```
$echo "<tag>Foo</tag>" | sed "s/[^<]*<\([^>]*\)>\([^<]*\)<\([^>]*\)>/[\1]\2[\3]/"

```

hope this helps.