I am trying to use back reference to match all occurrences of an imported class being instantiated using ripgrep
with the --pcre2
option enabled.
First I am looking to see if a class is being imported and then back referencing that to look up where it is instantiated.
First attempt: Matches the first occurrence of
new ExifInterface(str)
My regex is:(import.+(ExifInterface)).+(new\s\2\(.+\))
Second attempt: Matches the last occurrence of
new ExifInterface(str)
. My regex is(import.+(ExifInterface)).+(?:.+?(new\s\2\(.+\)))
My ripgrep
command is rg --pcre2 --multiline-dotall -U "(import.+(ExifInterface)).+(new\s\2\(.+?\))" -r '$3' -o
Question. How can i match all the occrrences of new ExifInterface(str)
Bonus question: In some cases, i am getting a PCRE2: error matching: match limit exceeded
stderr from rg
, but cant figure out why. The document length is only 161 lines.
Consider the following data sample:
import android.graphics.Point;
import android.media.ExifInterface;
import android.view.WindowManager;
import java.io.IOException;
public class MediaUtils {
/* renamed from: a */
public static float m13571a(String str) {
if (str == null || str.isEmpty()) {
throw new IllegalArgumentException("getRotationDegreeForImage requires a valid source uri!");
}
try {
int attributeInt = new ExifInterface(str).getAttributeInt("Orientation", 1);
if (attributeInt == 3) {
return 180.0f;
new ExifInterface(str).getAttributeInt("Orientation", 1);
}
if (attributeInt == 6) {
return 90.0f;
}