Regex Help

FrameXX

Well-known member
Hi.

I can't get this regex text extraction to work in MacroDroid no matter what:

I am using group 1 option.

If anybody is able to make it work I am courious.
 

bewafa

Member
On numerous occasions, I have encountered the same issue where the regular expression provided by ChatGPT 😂 was not executable on MacroDroid.
 

RSF

Well-known member
Looks like MacroDroid's extract function is limited to 5,000 characters -- when I run your example in MacroDroid I get exactly 5,000 characters in the extracted variable.

Is that the issue you're seeing? If so, might have to resort to a shell script....
 

Dimlos

Well-known member
I tried to tackle this difficult problem for a while, but the result was impossible.
I tried using shell scripts and Termux, but the results could not be imported into MacroDroid.
I tried to write the result to a file and read it, but only halfway through the file was read.
 

MacroDroidDev

Administrator
Staff member
I just tried changing the regex engine in regex101 to Java 8 (which I presume is the same engine as Android will use) and it comes up with the following error:

The Java regex engine reached the maximum call stack size.

This is due to the fact that the regex engine is implemented using recursion, and is severely limited by it. This indicates that your expression is not optimized for Java, and you are likely to run into similar issues in your Java code.

 

Dimlos

Well-known member
Maybe the extraction was successful because I used the python module instead of a regular expression.
However, I could not import the extraction result to MacroDroid.
 

RSF

Well-known member
Looks like MacroDroid's extract function is limited to 5,000 characters
I take this back. The issue is that when inspecting a variable's value in MacroDroid, only the first 5,000 characters are shown, at the bottom of a macro window. The value itself is OK.

I can't get this regex text extraction to work in MacroDroid no matter what:
See attached macro -- seems to work for me. What issue are you seeing?

(Note: the 2nd regex, in the disabled action, works as well. At first I thought your regex problem might be having a group () within a group (), so I changed the inner group to [\s\S] which gives the same result as your (?:.|\n). But both regex's work.)
 

Attachments

  • Regex_Q.macro
    388.1 KB · Views: 11

Dimlos

Well-known member
I thought you wanted to do a final JSON Parse, but when I tried it, I think there are too few variable items of dictionary type.
I'm just guessing, so maybe it would be better if the result is text.
 
Top