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.
How using Slipt syntax
Moderator: Martin
Re: How using Slipt syntax
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
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
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.
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
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 --'
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 664 times
Re: How using Slipt syntax
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)
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
@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.
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.
Code: Select all
message = findAll(sms, "flavio (.*)", true)[0][1];
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.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.