# Need help in function format string

**URL:** https://discourse.nodered.org/t/need-help-in-function-format-string/31734
**Category:** Developing Nodes
**Created:** [19 August 2020 14:20 UTC](https://discourse.nodered.org/t/need-help-in-function-format-string/31734 "2020-08-19T14:20:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![great12](https://avatars.discourse-cdn.com/v4/letter/g/35a633/32.png) [@great12](https://discourse.nodered.org/u/great12)
#### Post date: [19 August 2020 14:20 UTC](https://discourse.nodered.org/t/need-help-in-function-format-string/31734/1 "2020-08-19T14:20:27Z")

</div>

Hello there,

i'm very new to node-red.  
I'm trying my first steps, but stuck now.

i made a bash script, querying blacklist from spamhaus  
the output tells me, if there is an entry or not.

the function is as follows

var regExp = /.\*payload/; // search for payload  
var results = regExp.exec(msg.payload); // use as payload  
msg.payload = results; // show result of payload

msg.payload without function  
msg : Object

{ \_msgid: "44ca6ba5.d46494", payload: "mailserver not listed by sbl…", rc: object }

msg payload with function:  
function : (error)

"TypeError: Cannot read property '0' of null"

return msg;

aim should be a dashboard button, green if ok red if spam-listed

i hope someone could help me to solve, or give me a or some hints to my mistakes.

sry for my bad english

best regards e

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [19 August 2020 14:47 UTC](https://discourse.nodered.org/t/need-help-in-function-format-string/31734/2 "2020-08-19T14:47:46Z")

</div>

In case you don't realise, the message is a javascript object, not a string. Have a read of the node red docs [Working with Messages](https://nodered.org/docs/user-guide/messages).

If you still can't get it going then tell us what, for the given message, you want the function to pass on? Also tell us the full contents of msg.payload going in.

If posting code again use the `</>` button and paste the function there, that stops the forum from messing with the format.

[Edit] Sorry, I should have said welcome to the forum @great12

---

<div class="post-metadata">

### Author: ![great12](https://avatars.discourse-cdn.com/v4/letter/g/35a633/32.png) [@great12](https://discourse.nodered.org/u/great12)
#### Post date: [20 August 2020 05:01 UTC](https://discourse.nodered.org/t/need-help-in-function-format-string/31734/3 "2020-08-20T05:01:48Z")

</div>

Hello Colin,

thanks for your reply and hint, so i will walk through.  
and thanks for the welcome

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [19 October 2020 05:01 UTC](https://discourse.nodered.org/t/need-help-in-function-format-string/31734/4 "2020-10-19T05:01:51Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
