Question: in WSO2 api gateway I want to prototype a few POST requests using inline javascript. I am trying to figure out how to get the post body value which is going to be json. Its a pretty old version of WSO2 (I think v5.0).

```
//URL: /a/b/{u1}/c?p1=123
mc.setProperty('CONTENT_TYPE', 'application/json');
var u1 = mc.getProperty('uri.var.u1'); 
var p1 = mc.getProperty('query.param.p1');
var postBody = mc.getProperty(???????????);
mc.setPayloadJSON('{ "data" : "' + p1 + '|||' + p2+ '"}');

```

This script is correctly printing the values if they are in the query string or the URI but cant seem to figure out how to get the POST body.

Answer: 
Instead of using split, you might match the parts

```
<\/?at>|[^<>\s]+

```

[Regex demo](https://regex101.com/r/fHGtfx/1)

```js
const regex = /<\/?at>|[^<>\s]+/g;
console.log(`<at>foo bar</at>`.match(regex));
```

Using split, the pattern could be

```
,\s*|\s+|(?<=<at>)|(?=<\/at>)

```

```js
const regex = /,\s*|\s+|(?<=<at>)|(?=<\/at>)/g;
console.log(`<at>foo bar</at>`.split(regex))
```
Nice answer by @The fourth bird

Another way could be splitting only the string between the tags:

```js
const chars = "<at>foo bar</at>";

const tags = /<\/?at>/g;
const tokens = chars.replace(tags, "").split(/\s/);

const result = ["<at>", ...tokens, "</at>"]

console.log(result)
```