Regular expression in my trigger

Wjbell

Member
I'm using a word trigger in one of my macros and I'm using the regular expression check box so I can add regular expressions to my trigger word. Now I'm familiar in programming with perl but it's been a while and I'm not exactly sure how to do this in Mac Droid language. What I have right now is:

/locate/i

Which will trigger if the macro finds the word locate case insensitive. What I want is if it finds the word locate with or without whitespace after it. How would I write that?

/locate /i
 

tanutanu

Well-known member
I'm using a word trigger in one of my macros and I'm using the regular expression check box so I can add regular expressions to my trigger word. Now I'm familiar in programming with perl but it's been a while and I'm not exactly sure how to do this in Mac Droid language. What I have right now is:

/locate/i

Which will trigger if the macro finds the word locate case insensitive. What I want is if it finds the word locate with or without whitespace after it. How would I write that?

/locate /i
You don't need to put the regexp into slashes like Sed or Perl.
For case insensitive, (?i) might work. Normally I assign it as a parameter outside the expression in Java though.
So, the answer would be "(?i)locate *"(exclude double quote".
If you don't mind including tab, CR, LF or CRLF, you can use \s instead of invisible while space.
 

Wjbell

Member
You don't need to put the regexp into slashes like Sed or Perl.
For case insensitive, (?i) might work. Normally I assign it as a parameter outside the expression in Java though.
So, the answer would be "(?i)locate *"(exclude double quote".
If you don't mind including tab, CR, LF or CRLF, you can use \s instead of invisible while space.
Try try it exactly what you wrote no quotes and it didn't do anything. I guess it doesn't matter whether I use the forward slashes as delimiters because when I did

/locate/i

I could use capitals or lowercase and it would still trigger. That's an example of before I was worried about the space after the word. By the way, I'm using the matches radio button not the contains. So could I write it for the with or without white space afterwards using my delimiter style?
 

tanutanu

Well-known member
Try try it exactly what you wrote no quotes and it didn't do anything. I guess it doesn't matter whether I use the forward slashes as delimiters because when I did

/locate/i

I could use capitals or lowercase and it would still trigger. That's an example of before I was worried about the space after the word. By the way, I'm using the matches radio button not the contains. So could I write it for the with or without white space afterwards using my delimiter style?
Sorry, what's your problem?
 

Attachments

  • Screenshot_20211109-232819~2.png
    Screenshot_20211109-232819~2.png
    127.3 KB · Views: 26
  • Screenshot_20211109-232859~2.png
    Screenshot_20211109-232859~2.png
    122 KB · Views: 24
  • Screenshot_20211109-233204~2.png
    Screenshot_20211109-233204~2.png
    127 KB · Views: 20
  • Screenshot_20211109-233241~2.png
    Screenshot_20211109-233241~2.png
    124.6 KB · Views: 23

Wjbell

Member
Sorry, what's your problem?
Okay, first I don't even know where the screen that you posted screenshots of are. This is the screen I'm working with. I'm trying to use a regular expression oh, and I did click the regular expression radio box, 2 detect the word locate in a text message that is case insensitive and can have or cannot have a space after it. So if it reads the text and the word is written with capitals or lowercase it will still pass the rule and go on to an action. Now if the text happens to have a space after the word locate it will still pass the rule and go on to an action. That's what I want to do. And can I do it on this screen in my screenshot? And if so, how do I write that expression?
 

Attachments

  • Screenshot_20211109-063859.png
    Screenshot_20211109-063859.png
    71.5 KB · Views: 15

tanutanu

Well-known member
Okay, first I don't even know where the screen that you posted screenshots of are. This is the screen I'm working with. I'm trying to use a regular expression oh, and I did click the regular expression radio box, 2 detect the word locate in a text message that is case insensitive and can have or cannot have a space after it. So if it reads the text and the word is written with capitals or lowercase it will still pass the rule and go on to an action. Now if the text happens to have a space after the word locate it will still pass the rule and go on to an action. That's what I want to do. And can I do it on this screen in my screenshot? And if so, how do I write that expression?
I told sed or perl style delimiter causes the problem. It DOES the matter.
Screenshot_20211109-234954~2.png

Simply do the same thing as I wrote. Regexp on any triggers/actions/if conditions are the same thing, same class method is called.
index.php


If you want to match the regexp to anywhere in your string, do as the followings, whichever you want.
Screenshot_20211109-235858~2.pngScreenshot_20211109-235816~2.png
 

Attachments

  • Screenshot_20211109-235727~2.png
    Screenshot_20211109-235727~2.png
    120.9 KB · Views: 67

Wjbell

Member
I told sed or perl style delimiter causes the problem. It DOES the matter.
View attachment 1496

Simply do the same thing as I wrote. Regexp on any triggers/actions/if conditions are the same thing, same class method is called.
index.php


If you want to match the regexp to anywhere in your string, do as the followings, whichever you want.
View attachment 1498View attachment 1499
Okay thank you. Got it working per your suggestions with the contains bit. Just a little side note I wasn't sure what the red circle you were circling in an above screenshot was about
 

tanutanu

Well-known member
Okay thank you. Got it working per your suggestions with the contains bit. Just a little side note I wasn't sure what the red circle you were circling in an above screenshot was about
You're welcome:)
Jast a small tip, the text manipulation actions have features to test your regexp easily. Try it, it's very convenient. Probably you would no longer open your laptop for just a verification;)
The circled popup shows you the matching result. Nothing matched with the expression "/locale/i\s*" at that moment, so it was just a blank(increasing your screen brightness to check it. It was too dark).
"\s*" matches with continuous white space any times including zero time. So it should return the string if "/locale/i" matched with the string "locale" certainly when case insensitive. However, the letter slash and lower i streight matched as they are. The testing result shows the fact super clearly.
 

Wjbell

Member
You're welcome:)
Jast a small tip, the text manipulation actions have features to test your regexp easily. Try it, it's very convenient. Probably you would no longer open your laptop for just a verification;)
The circled popup shows you the matching result. Nothing matched with the expression "/locale/i\s*" at that moment, so it was just a blank(increasing your screen brightness to check it. It was too dark).
"\s*" matches with continuous white space any times including zero time. So it should return the string if "/locale/i" matched with the string "locale" certainly when case insensitive. However, the letter slash and lower i streight matched as they are. The testing result shows the fact super clearly.
Alright thanks again. Little off topic but I can't find the backslash character on my phone. Maybe I need a different keyboard I'm not sure.
 
Top