How using Slipt syntax

Post your questions and help other users.

Moderator: Martin

Post Reply
bricex308
Posts: 5
Joined: 25 Dec 2016 11:54

How using Slipt syntax

Post by bricex308 » 17 Nov 2019 12:52

Hi sorry for my english,

I wish how to use something like " Split " to cut a SMS text received and forward the second part of the message texte.

Trigger SMS received
Action a=SMS texte

....?Split?...

Action send sms sms sender...


I don't Know how write Split part...

Regard.

HumourMe
Posts: 9
Joined: 09 Nov 2019 14:13

Re: How using Slipt syntax

Post by HumourMe » 17 Nov 2019 14:51

I'm sure much better answers will be forthcoming but can you use:

List split(String s, String pattern)
Splits the string s into a list of strings by using the regular expression pattern as the delimiter. (see Regular expressions)

I'm guessing that you can save the message into say 'm'

then create a list:

lst = split(m, " ") //rather than " " use https://automagic4android.com/automagic ... terns.html to id the first split value.

The relevant modifiers are under quantifiers. Regex confuse me but I think lst = split(m, [" "?]) may be getting close to a split on the first space - but insert relevant pattern for testing!

lst[1] will then give you the second part.

or if the first part is always of the same length or format use replaceAll(String s, String regex, String replacement) to strip it out after identifying what to remove.

An example of what you are trying to split would help.

Source of functions: https://automagic4android.com/action_script_en.html

HumourMe
Posts: 9
Joined: 09 Nov 2019 14:13

Re: How using Slipt syntax

Post by HumourMe » 17 Nov 2019 17:18

Edit : thought I had a solution but didn't.

The best I can do is find the first part, then find and replace that with "". However there must be a more elegant way.

bricex308
Posts: 5
Joined: 25 Dec 2016 11:54

Re: How using Slipt syntax

Post by bricex308 » 17 Nov 2019 23:55

Hi sorry for this waiting...

For exemple i receive a SMS text :
from Victor :
"flavio don't try this and stay safe lol"

My flow need to do,
- trigger SMS received
- condition check if contact true ou false
- condition contains(sms_text, "flavio")
(***)
- ? (Stock SMS in variable I suppose...)
- ? ( Replace 'flavio' to ' ' or Split (Flavio/SMS text)
(Maybe : Result = replaceAll("variable_sms_text", "\p{Flavio}", " ");
(***)
- action Send SMS: to {number's flavio} 'don't try this and stay safe lol'

But between (***) i don't know really how write my syntaxe in action --'
Attachments
flow_Fw_flow_20191118_005421.xml
(2.1 KiB) Downloaded 649 times

HumourMe
Posts: 9
Joined: 09 Nov 2019 14:13

Re: How using Slipt syntax

Post by HumourMe » 18 Nov 2019 18:36

Sorry running out of time - how about this:

searchvar ="flavio";

message = "flavio don't try this and stay safe lol";

searchvar_length = length(searchvar);
searchvar_start = indexOf(message, searchvar);

result = subString(message, searchvar_start+searchvar_length-1)

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: How using Slipt syntax

Post by Desmanto » 22 Nov 2019 17:57

@bricex308 : You got it right for the contains(). If you need only "flavio" as the contact to send, after the expression, you only need one line scrript using regex.

Code: Select all

message = findAll(sms, "flavio (.*)", true)[0][1];
Use {message} in the send SMS, and put flavio's number.

I recommend to learn regex if you really need to use script and do a lot of data parsing like this. This is a very good video about it : https://www.youtube.com/watch?v=sa-TUpSx1JA

If the name can be anyone, you have to specify the sms properly. Use some code/syntax that is not normally used in sms, such as =:=. So your sms will be
"flavio=:=don't try this and stay safe lol"
It will be more specific and easier to splitted into 2 parts. You will get the name and the message. To find the number from the name, you can use aciton Query Content Provider.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply