Question: I have a variable in a stored procedure that contains a string of characters like

```
[Tag]MESSAGE[/Tag]

```

I need a way to get the `MESSAGE` part from within the tags.
Any help would be much appreciated

Answer: 
**Note:** I have tested it on Oracle RDBMS

A more reliable approach is to use **REGEXP\_REPLACE.**

```
REGEXP_REPLACE(value, pattern)

```

Example

```
SELECT  REGEXP_REPLACE(
        '<Tag>Message</Tag>',
         '\s*</?\w+((\s+\w+(\s*=\s*(".*?"|''.*?''|[^''">\s]+))?)+\s*|\s*)/?>\s*') FROM DUAL;

```

Just replace "<" with "[" if your tags are different
If the column contains only single tag, simple call of `substring` function should be enough. Otherwise there will always be some point where regular expression does not suffice since you fall into [trap (see this legendary StackOverflow answer)](https://stackoverflow.com/a/1732454/653539).