Improve Replace all of Text manipulation action

nhanqv

New member
Text to replace only support regex. So if Text to replace contains special characters such as ? /$, it need to be escaped before using. It become complicated for normal user.


Could you add support for simple Text to replace (without regex) ?
Screenshot_20210512-215918.jpg
 

nhanqv

New member
Would you like to share an example?
For example
Source text: (x1+y1)/z1;(x2+y2)/z2;(x1+y1)/z1;

To replace all occurrences of "(x1+y1)/z1", it must to define Text to replace: \(x1\+y1\)/z1

index.php
 

Attachments

  • Screenshot_20210513-060356.png
    Screenshot_20210513-060356.png
    89.3 KB · Views: 42

Dm114

Well-known member
Text to replace only support regex. So if Text to replace contains special characters such as ? /$, it need to be escaped before using. It become complicated for normal user.


Could you add support for simple Text to replace (without regex) ?
View attachment 411
You don't seem to be a 'normal user' (your word) as you know how to escape special characters! 😉

As you already know and wrote the syntax, why wouldn't you create a routine (macro function) to 'translate in regex language' a text stored in a string variable you transform in an output string variable you'll use in 'Replace (regex)' action in the calling macro?
 

nhanqv

New member
That's right. I'm a Programmer

I have already made a function to escape all regex special characters.
But it's quite complicated for normal user.

So I think Macrodroid should support plain text for Text to replace

20210514_052403.png
 

tanutanu

Well-known member
Probably shell builtin replace is easy in this case :unsure:

STR='(x1+y1)/z1;(x2+y2)/z2;(x1+y1)/z1'; STR=${STR//(x1+y1)\/z1/}; echo "$STR"

Only single "/" needs to escape. I dont know which better way is for newbies or lite users though. MD make a good opportunity to learn regexp:)
 
Top