I am trying to get the position of a special character in an array using tasker but I have had no luck. I have tried the following %Variable(#?+) but this returns 0. I tried this because if you are trying to get the position of a word in an array you type in %Variable(#?data)however this does not work for special characters.
Asked
Active
Viewed 523 times
0
-
1Please provide some sample inputs and outputs in your question. What do you mean by special character? – Robo Mop Feb 29 '20 at 12:15
-
The input is %Variable(#?+), with the special character as +. The output would be 0 if nothing is found or the number of positon of the character. Don't worry I have found a solution now it should be %Variable(#?~R\+). Thanks for your response. – nigel mhizha Feb 29 '20 at 13:29
1 Answers
0
As per Tasker Pattern Matching documentation, "Standard Java regular expression matching is applied" "wherever a Simple Match is possible, by preceding the regex with ~R or !~R".
Thus you need to escape the +
and use ~R
:
%Variable(#?~R\+)

Wiktor Stribiżew
- 607,720
- 39
- 448
- 563