# Is there a way to do string - string?

**URL:** <https://discourse.nodered.org/t/is-there-a-way-to-do-string-string/53009>\
**Category:** General\
**Created:** [31 October 2021 11:58 UTC](https://discourse.nodered.org/t/is-there-a-way-to-do-string-string/53009 "2021-10-31T11:58:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BioKeks](https://avatars.discourse-cdn.com/v4/letter/b/57b2e6/32.png) [@BioKeks](https://discourse.nodered.org/u/BioKeks)\
**Post date:** [31 October 2021 11:58 UTC](https://discourse.nodered.org/t/is-there-a-way-to-do-string-string/53009/1 "2021-10-31T11:58:29Z")

</div>

Hey guys!  
I have 2 strings in the msg. (first string msg.hello, second msg.cookie)  
The problem I have is **msg.hello** contains words that I don't want in msg.hello.  
**msg.cookie** contains the words that I want to delete from msg.hello.  
Example:  
**msg.hello** = "I love Node Red because";  
**msg.cookie** = "because";

Is there a way to do something like **msg.hello** - **msg.cookie**?  
msg.hello should look in the end "I love Node Red".

Hope somebody can help me!

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [31 October 2021 12:03 UTC](https://discourse.nodered.org/t/is-there-a-way-to-do-string-string/53009/2 "2021-10-31T12:03:52Z")

</div>

This might/should work  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/0/70c3a021990ca8a095ed96f4832bf37e479d7bb5.png)

---

<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:** [31 October 2021 13:33 UTC](https://discourse.nodered.org/t/is-there-a-way-to-do-string-string/53009/3 "2021-10-31T13:33:15Z")

</div>

> [@BioKeks](#):
>
> **msg.cookie** contains the words that I want to delete from msg.hello

I suspect the change node will only work if there is just one word in msg.cookie. You said 'words' in your message which suggests more than one.  
Also check what happens if msg.cookie is an empty string (if that can ever happen) or does not exist at all.

---

<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:** [14 November 2021 13:33 UTC](https://discourse.nodered.org/t/is-there-a-way-to-do-string-string/53009/4 "2021-11-14T13:33:24Z")

</div>

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