# How to - two keywords to drop a string

**URL:** <https://discourse.nodered.org/t/how-to-two-keywords-to-drop-a-string/47064>\
**Category:** General\
**Created:** [12 June 2021 10:23 UTC](https://discourse.nodered.org/t/how-to-two-keywords-to-drop-a-string/47064 "2021-06-12T10:23:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikozo](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vikozo](https://discourse.nodered.org/u/vikozo)\
**Post date:** [12 June 2021 10:23 UTC](https://discourse.nodered.org/t/how-to-two-keywords-to-drop-a-string/47064/1 "2021-06-12T10:23:35Z")

</div>

Hello  
i got a string and insyde i will have some keyword, if they come the packet have to be dropped. And important both keyword have to be in this string to drop

"UNKNOWN" and "Not confirmed"

i would like to use the Switch Node so a rule would be if fit both drop (empty output) else the packet will go to the next node to prozess.

```auto
[{"id":"6e1dd3f1.f0e5cc","type":"switch","z":"788a1dca.e79704","name":"\"CRC ERROR\"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"\"UNKNOWN\" and \"Not confirmed\"","vt":"msg"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":180,"y":3120,"wires":[["971290e7.87919"],["94716062.98783","b5c6905.95db87"]]}]

```

what i have no is not working like this. ;-(  
have a nice day  
vinc

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [12 June 2021 10:50 UTC](https://discourse.nodered.org/t/how-to-two-keywords-to-drop-a-string/47064/2 "2021-06-12T10:50:34Z")

</div>

try a JSONata expression  
e.g.

```auto
[{"id":"6e1dd3f1.f0e5cc","type":"switch","z":"c74669a0.6a34f8","name":"\"CRC ERROR\"","property":"payload","propertyType":"msg","rules":[{"t":"jsonata_exp","v":"$contains(payload,\"UNKNOWN\") and $contains(payload,\"Not confirmed\")","vt":"jsonata"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":250,"y":4020,"wires":[[],["27aae039.40c52"]]}]

```

Or use Regex or two switch nodes in series

---

<div class="post-metadata">

**Author:** ![vikozo](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vikozo](https://discourse.nodered.org/u/vikozo)\
**Post date:** [12 June 2021 15:07 UTC](https://discourse.nodered.org/t/how-to-two-keywords-to-drop-a-string/47064/3 "2021-06-12T15:07:06Z")

</div>

@E1cid  
thanks a lot, to read it seems so simple!  
And had to wait for getting packets with error .  
and it works great, thanks a lot  
have a nice day  
vinc

---

<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:** [11 August 2021 15:07 UTC](https://discourse.nodered.org/t/how-to-two-keywords-to-drop-a-string/47064/4 "2021-08-11T15:07:13Z")

</div>

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