<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title>www.ritlabs.com [Topic: A little lost with REGEXP]</title>
		<link>http://www.ritlabs.com</link>
		<description>New posts in A little lost with REGEXP of  forum at www.ritlabs.com [www.ritlabs.com]</description>
		<language>en</language>
		<docs>http://backend.userland.com/rss2</docs>
		<lastBuildDateTag>Tue, 11 Jan 2022 01:18:46 +0200</lastBuildDateTag>		<item>
			<title>A little lost with REGEXP</title>
			<description><![CDATA[<b><a href="http://www.ritlabs.com/en/forums/forum5/topic14284/message52844/">A little lost with REGEXP</a></b> <i>Trying to work out how to reduce a string</i> in forum <a href="http://www.ritlabs.com/en/forums/forum5/">The Bat! - Filters</a>. <br />
			The Bat! serves very well the regular expressions, but it has some limitations and differences comparing to Perl language. First, you have to define and use reply template to reply messages received from LoRa gateway. These replies should be directed to SMS gateway, and you have to configure it in the reply template. I checked combination of macros with regular expressions and here is working example of reply template:<br /><br /><B>Assumptions</B>:<br /><ol><li>String being a result of original LoRa message will be inserted in the variable callled here <B>%_LoRa</B>. I do not know how to get this string, but assigning it to the variable is simple in the reply template: <B>%_LoRa=&quot;string&quot;</B>.<br /><li>Assume the e-mail address of SMS gateway is <B><noindex><a href="mailto:SMS@gate.way" target="_blank" rel="nofollow">SMS@gate.way</a></noindex></B>.<br /></ol>
====code====
<pre>%To=""%-
%To="SMS@gate.way"%-
%_LoRa="string"%-
%SetPattRegexp="(?im)(^.*)(&#92;(&#92;d+&#92;)).*?T(emperature) is (&#92;d+).* &#92;xB0C.*?(exceeded) the t(hreshold )(&#92;d+) (&#92;xB0C)&#92;.(Date.*?UTC&#92;+&#92;d+)(.*&#92;xB0C)(Humidity:&#92;d+&#92;.&#92;d).*"%-
%RegexpBlindMatch="%_LoRa"%-
%SubPatt="1" %SubPatt="2" %SubPatt="10" %SubPatt="11"%
T%SubPatt="6" %SubPatt="5" %SubPatt="7" %SubPatt="8"
%SubPatt="9"</pre>
=============
You should insert this code, e.g., in a quick template, remembering to modify it (real address of SMS gateway and source of analysed original string). You should obtain the following result (from your example string):<br /><br />
====code====
<pre>Alert FSI-Temp 3 (641093042320) Temperature:42.8 °C Humidity:19.5%
Threshold&nbsp;&nbsp;exceeded 30 °C
Date:2019-10-12 14:55:44 UTC+10</pre>
============= <br />
			<i>11 January 2022 01:18:46, <a href="http://www.ritlabs.com/en/forums/">Zygmunt Wereszczyński</a>.</i>]]></description>
			<link>http://www.ritlabs.com/en/forums/forum5/topic14284/message52844/</link>
			<guid>http://www.ritlabs.com/en/forums/forum5/topic14284/message52844/</guid>
			<pubDate>Tue, 11 Jan 2022 01:18:46 +0200</pubDate>
			<category>The Bat! - Filters</category>
		</item>
		<item>
			<title>A little lost with REGEXP</title>
			<description><![CDATA[<b><a href="http://www.ritlabs.com/en/forums/forum5/topic14284/message52079/">A little lost with REGEXP</a></b> <i>Trying to work out how to reduce a string</i> in forum <a href="http://www.ritlabs.com/en/forums/forum5/">The Bat! - Filters</a>. <br />
			I'll trust that it works.. <img src="http://www.ritlabs.com/bitrix/images/main/smiles/5/icon_smile.gif" border="0" data-code=":)" data-definition="SD" alt=":)" style="width:16px;height:16px;" title="" class="bx-smile" /> &nbsp; Brilliant, Ariel, thank you for posting this. <br /><br />To me, regex (along with code written in C) always looks so abstract that I do not even attempt to decypher it.. &nbsp;<img src="http://www.ritlabs.com/bitrix/images/main/smiles/5/icon_eek.gif" border="0" data-code=":o" data-definition="SD" alt=":o" style="width:16px;height:16px;" title="" class="bx-smile" /> <br />
			<i>29 July 2021 23:54:48, <a href="http://www.ritlabs.com/en/forums/">Daniel van Rooijen</a>.</i>]]></description>
			<link>http://www.ritlabs.com/en/forums/forum5/topic14284/message52079/</link>
			<guid>http://www.ritlabs.com/en/forums/forum5/topic14284/message52079/</guid>
			<pubDate>Thu, 29 Jul 2021 23:54:48 +0300</pubDate>
			<category>The Bat! - Filters</category>
		</item>
		<item>
			<title>A little lost with REGEXP</title>
			<description><![CDATA[<b><a href="http://www.ritlabs.com/en/forums/forum5/topic14284/message52077/">A little lost with REGEXP</a></b> <i>Trying to work out how to reduce a string</i> in forum <a href="http://www.ritlabs.com/en/forums/forum5/">The Bat! - Filters</a>. <br />
			I know this question was asked a long time ago, but perhaps someone might be interested<br /><br />Tested string:<br />&quot;<br />Alert FSI-Temp 3 (641093042320)Content:The temperature is 42 ℃, which has exceeded the threshold 30 ℃.Date:2019-10-12 14:55:44 UTC+10Temperature:42.8 ℃Humidity:19.5 %Note: The listed data was updated at 2019-10-12 14:55:24 UTC+10 &nbsp;iOS Android Official Website &nbsp;Ursalink Cloud &nbsp;Contact Us<br />&quot;<br /><br />Regex:<br />&quot;<br />(^.* )(\(\d+\)).*?(emperature) is (\d+).* ℃.*?(exceeded) the t(hreshold )(\d+) (℃)\.(Date.*?UTC\+\d+)(.*℃)(&#91;^:&#93;+):(&#91;^ %&#93;+).*<br />&quot;<br /><br />Replaced with:<br />&quot;<br />$1$2 T$3: $4$8 $11: $12%\nT$6$5 $7$8.\n$9<br />&quot;<br /><br />I haven&#39;t tested this in The Bat!, but it works in <noindex><a href="https://regexr.com/4lvrs" target="_blank" rel="nofollow">https://regexr.com/4lvrs</a></noindex><br />Good luck. <br />
			<i>29 July 2021 03:48:49, <a href="http://www.ritlabs.com/en/forums/">Ariel Karluk</a>.</i>]]></description>
			<link>http://www.ritlabs.com/en/forums/forum5/topic14284/message52077/</link>
			<guid>http://www.ritlabs.com/en/forums/forum5/topic14284/message52077/</guid>
			<pubDate>Thu, 29 Jul 2021 03:48:49 +0300</pubDate>
			<category>The Bat! - Filters</category>
		</item>
		<item>
			<title>A little lost with REGEXP</title>
			<description><![CDATA[<b><a href="http://www.ritlabs.com/en/forums/forum5/topic14284/message47993/">A little lost with REGEXP</a></b> <i>Trying to work out how to reduce a string</i> in forum <a href="http://www.ritlabs.com/en/forums/forum5/">The Bat! - Filters</a>. <br />
			Sadly I suck at RegEx, so I cannot help you, but the good news is that Regular Expressions are a universal language and The Bat is only one of thousands of applications that use them. So, if you cannot find the answer here, you could also ask your question in basically any forum dedicated to programming in general or to RegEx in particular. <br />
			<i>12 October 2019 14:34:30, <a href="http://www.ritlabs.com/en/forums/">Daniel van Rooijen</a>.</i>]]></description>
			<link>http://www.ritlabs.com/en/forums/forum5/topic14284/message47993/</link>
			<guid>http://www.ritlabs.com/en/forums/forum5/topic14284/message47993/</guid>
			<pubDate>Sat, 12 Oct 2019 14:34:30 +0300</pubDate>
			<category>The Bat! - Filters</category>
		</item>
		<item>
			<title>A little lost with REGEXP</title>
			<description><![CDATA[<b><a href="http://www.ritlabs.com/en/forums/forum5/topic14284/message47990/">A little lost with REGEXP</a></b> <i>Trying to work out how to reduce a string</i> in forum <a href="http://www.ritlabs.com/en/forums/forum5/">The Bat! - Filters</a>. <br />
			I have a rather complex string I would like to shorten and forward to an SMS gateway. initially the message came from a LoRa gateway that sends in HTML format and to be honest it is a real mess. Thankfully The Bat takes care of most of that and chops is down to plain text. however there is still information that is not needed.<br /><br />The string is Alert FSI-Temp 3 (641093042320)Content:The temperature is 42 ℃, which has exceeded the threshold 30 ℃.Date:2019-10-12 14:55:44 UTC+10Temperature:42.8 ℃Humidity:19.5 %Note: The listed data was updated at 2019-10-12 14:55:24 UTC+10 &nbsp;iOS Android Official Website &nbsp;Ursalink Cloud &nbsp;Contact Us<br /><br /><br />All i really need from that is something like this..<br /><br /><br /><br />Alert FSI-Temp 3 (641093042320) Temperature:42.8 ℃Humidity:19.5 %<br />Threshold exceeded 30 ℃. <br />Date:2019-10-12 14:55:44 UTC+10<br /><br />FSI-Temp 3 is the Name of the sensor and will change<br />(641093042320) is the ID of the sensor and will change<br /><br />Would anyone please be able to assist me in creating an expression to filter this information so it can be forwarded to the SMS gateway.<br /><br />Regards<br />Andrew <br />
			<i>12 October 2019 12:58:19, <a href="http://www.ritlabs.com/en/forums/">Andrew Hooper</a>.</i>]]></description>
			<link>http://www.ritlabs.com/en/forums/forum5/topic14284/message47990/</link>
			<guid>http://www.ritlabs.com/en/forums/forum5/topic14284/message47990/</guid>
			<pubDate>Sat, 12 Oct 2019 12:58:19 +0300</pubDate>
			<category>The Bat! - Filters</category>
		</item>
	</channel>
</rss>
