Page 1 of 1

How using Slipt syntax

Posted: 17 Nov 2019 12:52
by bricex308
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.

Re: How using Slipt syntax

Posted: 17 Nov 2019 14:51
by HumourMe
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

Re: How using Slipt syntax

Posted: 17 Nov 2019 17:18
by HumourMe
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.

Re: How using Slipt syntax

Posted: 17 Nov 2019 23:55
by bricex308
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 --'

Re: How using Slipt syntax

Posted: 18 Nov 2019 18:36
by HumourMe
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)

Re: How using Slipt syntax

Posted: 22 Nov 2019 17:57
by Desmanto
@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.