# REGEX Question using JSONata (Change node)

**URL:** <https://discourse.nodered.org/t/regex-question-using-jsonata-change-node/42092>\
**Category:** General\
**Created:** [5 March 2021 14:39 UTC](https://discourse.nodered.org/t/regex-question-using-jsonata-change-node/42092 "2021-03-05T14:39:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vongomben](https://avatars.discourse-cdn.com/v4/letter/v/a4c791/32.png) [@vongomben](https://discourse.nodered.org/u/vongomben)\
**Post date:** [5 March 2021 14:39 UTC](https://discourse.nodered.org/t/regex-question-using-jsonata-change-node/42092/1 "2021-03-05T14:39:43Z")

</div>

Hi.  
I'm trying to extract "Total: $10.00" from this text

```auto
02-01 00:00 02-28 23:59$10.00 $0.00 $10.00Subtotal: $10.00Tax: $0.00Total: $10.00Thanks for your purchase!Please do not hesitate to contact us if you have any questions.(View as PDF...

```

[I'm successfully doing it](https://regex101.com/r/Wim3Nx/1) with this:

```auto
Total:\s\$\d+.\d+

```

But when I inject it in a change node, nothing comes out.  
This is proably related to the fact that I'm not using in the correct way the $match commant in JSONata

```auto
$match(payload,(Total:\s\$\d+.\d+))

```

My flow in attach, any help appreciated!

```auto
[{"id":"ba8c73b6.b5d17","type":"inject","z":"2df38b47.f4ff84","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"02-01 00:00 02-28 23:59$10.00 $0.00 $10.00Subtotal: $10.00Tax: $0.00Total: $10.00Thanks for your purchase!Please do not hesitate to contact us if you have any questions.(View as PDF...","payloadType":"str","x":1160,"y":840,"wires":[["529c5bfb.1b23a4","c7362f00.e73c4"]]},{"id":"76a729e7.abf3e8","type":"debug","z":"2df38b47.f4ff84","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1590,"y":840,"wires":[]},{"id":"17006627.8045ba","type":"debug","z":"2df38b47.f4ff84","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1610,"y":880,"wires":[]},{"id":"529c5bfb.1b23a4","type":"change","z":"2df38b47.f4ff84","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$match(payload,(Total:\\s\\$\\d+.\\d+))","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1400,"y":840,"wires":[["76a729e7.abf3e8"]]},{"id":"c7362f00.e73c4","type":"switch","z":"2df38b47.f4ff84","name":"","property":"payload","propertyType":"msg","rules":[{"t":"regex","v":"(Total:\\s\\$\\d+.\\d+)","vt":"env","case":false}],"checkall":"true","repair":false,"outputs":1,"x":1370,"y":880,"wires":[["17006627.8045ba"]]}]

```

---

<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:** [5 March 2021 14:55 UTC](https://discourse.nodered.org/t/regex-question-using-jsonata-change-node/42092/2 "2021-03-05T14:55:02Z")

</div>

Try

```auto
$match(payload,/Total:\s\$\d+.\d+/) // should return Total: $10.00
$match(payload,/(?<=Total:\s)\$\d+.\d+/) // should return $10.00

```

---

<div class="post-metadata">

**Author:** ![vongomben](https://avatars.discourse-cdn.com/v4/letter/v/a4c791/32.png) [@vongomben](https://discourse.nodered.org/u/vongomben)\
**Post date:** [5 March 2021 15:03 UTC](https://discourse.nodered.org/t/regex-question-using-jsonata-change-node/42092/3 "2021-03-05T15:03:08Z")

</div>

thanks so much!

---

<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:** [4 May 2021 15:03 UTC](https://discourse.nodered.org/t/regex-question-using-jsonata-change-node/42092/4 "2021-05-04T15:03:16Z")

</div>

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