Extract and store partial value from a Notification String in Variable

Muralidaran

New member
Hi,
I'm facing difficulty in extracting and storing a partial value from a Notification String in Variable, i have tried the below but with no luck so landed here for experts opinion and suggestions.

[not_title] = You have spent in amazon of value 61.4567

Text Manipulation 'to extract 'amazon'
Substring
Source Text = [not_title]
Start Index = 19
End Index = 6 'this is not a fixed length currently I'm using a fixed length (need to identify the blank space after start index 19)
Save to variable = Shop 'Created the varible in Home tab Variable menu with the type as String

For me the steps seems good but for some unknown reason the variable is empty after the trigger is fired, i have confirmed that the trigger worked by adding a sound after this text maipulation step.

Requesting your suggestion on this, thanks.
 

tanutanu

Well-known member
Hi,
I'm facing difficulty in extracting and storing a partial value from a Notification String in Variable, i have tried the below but with no luck so landed here for experts opinion and suggestions.

[not_title] = You have spent in amazon of value 61.4567

Text Manipulation 'to extract 'amazon'
Substring
Source Text = [not_title]
Start Index = 19
End Index = 6 'this is not a fixed length currently I'm using a fixed length (need to identify the blank space after start index 19)
Save to variable = Shop 'Created the varible in Home tab Variable menu with the type as String

For me the steps seems good but for some unknown reason the variable is empty after the trigger is fired, i have confirmed that the trigger worked by adding a sound after this text maipulation step.

Requesting your suggestion on this, thanks.
You need to assign 19+6 value as the ending index.
Note that the result should be starting "m"(Amazon's m) as your example. It counts index starting from the number zero, 0,1,2,3...
 

Muralidaran

New member
Hi,
Thanks for your suggestion, tried it still the value is not stored in variable (macro triggered).
attached images for reference.
 

Attachments

  • Screenshot_20211119_121702_com.arlosoft.macrodroid.jpg
    Screenshot_20211119_121702_com.arlosoft.macrodroid.jpg
    278.8 KB · Views: 55
  • Screenshot_20211119_121713_com.arlosoft.macrodroid.jpg
    Screenshot_20211119_121713_com.arlosoft.macrodroid.jpg
    239.9 KB · Views: 49

tanutanu

Well-known member
Hi,
Thanks for your suggestion, tried it still the value is not stored in variable (macro triggered).
attached images for reference.
It works. So the problem is hidden in the magic text variable you refered.
Add a test popup and/or put it in a variable action to show the notification title. Probably you would missed to get it.

Anyway, I think extract text is easier for your case, especially the string would be changing.
 

Attachments

  • Screenshot_20211119-182339~2.png
    Screenshot_20211119-182339~2.png
    146.8 KB · Views: 43
  • Screenshot_20211119-183852~2.png
    Screenshot_20211119-183852~2.png
    111.1 KB · Views: 47
  • Screenshot_20211119-183824~2.png
    Screenshot_20211119-183824~2.png
    103.1 KB · Views: 39
  • Screenshot_20211119-184134~2.png
    Screenshot_20211119-184134~2.png
    112.4 KB · Views: 41
  • Screenshot_20211119-184504~2.png
    Screenshot_20211119-184504~2.png
    130.2 KB · Views: 44

tanutanu

Well-known member
Hi,
Thanks for your suggestion, tried it still the value is not stored in variable (macro triggered).
attached images for reference.
The string what you want might be notification message body, not the title. You can get it with the magic text, [notification], as well:)
 

Dm114

Well-known member
Hi,
I'm facing difficulty in extracting and storing a partial value from a Notification String in Variable, i have tried the below but with no luck so landed here for experts opinion and suggestions.

[not_title] = You have spent in amazon of value 61.4567

Text Manipulation 'to extract 'amazon'
Substring
Source Text = [not_title]
Start Index = 19
End Index = 6 'this is not a fixed length currently I'm using a fixed length (need to identify the blank space after start index 19)
Save to variable = Shop 'Created the varible in Home tab Variable menu with the type as String

For me the steps seems good but for some unknown reason the variable is empty after the trigger is fired, i have confirmed that the trigger worked by adding a sound after this text maipulation step.

Requesting your suggestion on this, thanks.
Why wouldn't you extract with regex '\d+\.\d+' (without quotes) ?
 
Top