Pattern Match find/search a person name usign regex in tasker

992 views
Skip to first unread message

Emamuddin Shah

unread,
Mar 10, 2016, 11:46:51 PM3/10/16
to Tasker
Hello Team,

iam not a developer, but i like playing with tasker and basic stuffs

Please help,

i have a file and i splitted into variable %Myvar, it has person names like ("Rakesh Kumar", Ajit Singh" etc...)

i have user query %Myquery to input person name

iam able to do if iam writing full name(Rakesh Kumar) in %Myquery iam able to match with %Myvar()

I want regex to match partial name to %Myvar()

if i write Rakes  it should match to "Rakesh Kumar" 

please help with regex expression or any other way to match in tasker

thanks

Rich D

unread,
Mar 11, 2016, 6:04:12 AM3/11/16
to Tasker Google Groups Post


> I want regex to match partial name to %Myvar()
>
> if i write Rakes  it should match to "Rakesh Kumar" 

It can most likely be done with a regex match but because the string is not consistent it gets a bit tricky (IE there is no comma in the beginning or end ) there are many regex builders on line if nobody posts it here.

The other way it can be done is with a array search.  Check the user guide under 'Variables'  for this ..

%arr(#?b/c)
A comma-separated list of the array indices (lowest to highest) with matching values, or 0 if none match (2,3 in the example)

Then you would search for *Rakes*

Emamuddin Shah

unread,
Mar 11, 2016, 6:10:24 AM3/11/16
to tas...@googlegroups.com

Thanks,

I got with array search by using

%array(#?%variable+)

It works fine,  until there is no "." in string.

--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/gbgpX5MJRK0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.

Rich D

unread,
Mar 11, 2016, 6:36:40 AM3/11/16
to Tasker Google Groups Post

> %array(#?%variable+)

That should work fine if you are always looking for the first name.

>
> It works fine,  until there is no "." in string.

Not sure what you mean by that. Where would a  "." Or lack of a "." Couse this to fail?

Emamuddin Shah

unread,
Mar 11, 2016, 9:31:40 AM3/11/16
to tas...@googlegroups.com

But sometimes it throws error,  I want to type only partial name and get details.. If anyone please let me know

--

Emamuddin Shah

unread,
Mar 11, 2016, 9:32:53 AM3/11/16
to tas...@googlegroups.com

It works for  Rakesh Kumar but not for Deepak RP... Any idea

On 11-Mar-2016 17:06, "Rich D" <ricp...@gmail.com> wrote:
--

Dale Smith

unread,
Mar 11, 2016, 10:29:52 AM3/11/16
to Tasker
I think it would be useful for you to post your task(s). To post your profile or task here...  Long press on the profile or task name / ( 3 dot menu with 4.0+ ) export / export "DESCRIPTION" to clipboard (not XML)

Any linked tasks will be exported with the profile they are linked to..

To be able to export, The beginner mode needs to be off and the profile needs to be named by you (Not the Tasker listed name.  Tasker will list your profile with the context name if you have not given it one).

Emamuddin Shah

unread,
Mar 11, 2016, 10:31:48 AM3/11/16
to tas...@googlegroups.com

Here it goes,

Saleswar (36)
A1: Read File [ File:DropsyncFiles/sales3.csv To Var:%Mycal ] 
A2: Variable Split [ Name:%Mycal Splitter:, Delete Base:Off ] 
A3: Variable Query [ Title:Data Variable:%Myquery Input Type:Normal Text Default: Background Image: Layout:Variable Query Timeout (Seconds):36 Show Over Keyguard:On ] 
A4: Variable Set [ Name:%Mdtt To:%Mycal(#?%Myquery+) Do Maths:Off Append:Off ] 
A5: Variable Set [ Name:%Mycaln To:%Mdtt+1 Do Maths:On Append:Off ] 
A6: Flash [ Text:Here is your details %Mycal(%Mdtt) Long:Off ] 
A7: Set Clipboard [ Text:%Mycal(%Mycaln) Add:Off ] 
A8: Variable Clear [ Name:%Mdtt Pattern Matching:Off ] 

Emamuddin Shah

unread,
Mar 11, 2016, 10:35:19 AM3/11/16
to tas...@googlegroups.com

My Query is simple I will type few letter (Rak) it should match with persons full name(Rakesh Kumar) and get data

Rich D

unread,
Mar 11, 2016, 4:44:34 PM3/11/16
to Tasker Google Groups Post


But sometimes it throws error,

What is the error? 
Turn on pop up errors in preferences. Or run task with play button to see the error.

> It works for  Rakesh Kumar but not for Deepak RP... Any idea

You would have to post the contents of the array and exactly what you input for a query.

>> > %array(#?%variable+)

This will not match if you enter the full name. This requires a character 'after' your query.

I would use..
%array(#?%variable*)

The results of this search are a "comma-separated list" of the array indices.  So if you happen to get 2 matches you can not use the results as a integer.  You need to test the results to see if there are more then one match or if it is equal to zero (no matches) 

Rich D

unread,
Mar 11, 2016, 4:49:05 PM3/11/16
to Tasker Google Groups Post

I would also convert (action/ variable/variable convert) your query to lowercase. This will match any combination of lower and upper case. If you have any uppercase characters in the query then it needs to be a exact match.

Rich D

unread,
Mar 11, 2016, 4:53:41 PM3/11/16
to Tasker Google Groups Post


> The results of this search are a "comma-separated list" of the array indices.  So if you happen to get 2 matches you can not use the results as a integer.  You need to test the results to see if there are more then one match or if it is equal to zero (no matches) 

In regards to this.. since there is always a result you can safely just split the resulting variable. Then test for if %var2 is set or if %var1=0

Emamuddin Shah

unread,
Mar 11, 2016, 10:26:27 PM3/11/16
to tas...@googlegroups.com

Hii Team,  i got answer,  actually if there are more pattern matching it was throwing error.

Than I did this,

Saleswar1 (2)


A1: Read File [ File:DropsyncFiles/sales3.csv To Var:%Mycal ]
A2: Variable Split [ Name:%Mycal Splitter:, Delete Base:Off ]

A3: Variable Query [ Title:Candidate Name Variable:%Myquery Input Type:Normal Text Default: Background Image: Layout:Variable Query Timeout (Seconds):41 Show Over Keyguard:On ]

A4: Variable Set [ Name:%Mdtt To:%Mycal(#?%Myquery+) Do Maths:Off Append:Off ]

A5: If [ %Mdtt eq 0 ]
A6: Goto [ Type:Action Number Number:15 Label: ]
A7: End If
A8: Variable Split [ Name:%Mdtt Splitter:, Delete Base:Off ]
A9: Variable Set [ Name:%Mdtta To:%Mdtt(#)  Do Maths:On Append:Off ]
A10: Variable Set [ Name:%Mdttb To:%Mdtt(%Mdtta) Do Maths:Off Append:Off ]
A11: Variable Set [ Name:%Mdttc To:%Mdttb+1 Do Maths:On Append:Off ]
A12: Variable Set [ Name:%Mdttd To:%Mdttb-1 Do Maths:On Append:Off ]
A13: Flash [ Text:Here is details of %Mycal(%Mdttb)     ( %Mdtta) for %Mycal(%Mdttd) Long:Off ]
A14: Set Clipboard [ Text:%Mycal(%Mdttc) Add:Off ]
A15: Array Clear [ Name:%Mycal ]
A16: Variable Clear [ Name: Pattern Matching:Off ]
A17: Flash [ Text:Data not found Long:Off ] If [ %Mdtt eq O ]

Its working fine.

--
Reply all
Reply to author
Forward
0 new messages