Question: Good Morning DBA's, 
I need a function to pulls an int DocumentID column and returns the lowest thousand int. The limitation is our result must have 8 chars and the leading characters need to be 0's. 

* **Example 1**: 1234 (int contained in DocumentID column) Result: 00001000
(generated by function in result set)
* **Example 2**: 1152534 Result: 01152000

Result Set...

```
DocumentID Function 

1234       00001000 
1152534    01152000

```

Answer: 
You could use a regex replace callback like so:

```
var codes = [];
var message = $("#userMessage").html();//however you're fetching the message
message.replace(/(\w+:)(\w+)/g,function(a,b,c) {
    codes.push(c);
});
console.log(codes);//["_27265", "U_AW_GEN_M"]

```

This particular bit of code works with any sets of codes, i.e. if you added to the end of that sentence `Foo:bar`, the result above would be `["_27265", "U_AW_GEN_M", "bar"]`

If you don't want that, change the regex to: `/(Message|Task):(\w+)/g`

**Associative object**

```
var Codes = {};
var message = $("#userMessage").html();//however you're fetching the message
message.replace(/(\w+):(\w+)/g,function(a,b,c) {
    Codes[b]=c;
});
console.log(Codes);//{Message:"_27265",Task:"U_AW_GEN_M"}

```

You can then access the task code, for example, with `Codes.Task`
```
var a = "Message:_27265. Task:U_AW_GEN_M";
var msg = a.split(":")[1].split(".")[0];
var task = a.split(":")[2];

console.log(msg+"---"+task);

```