0

How Can I match XX.Xx("$\bH.Pt#S+V0&DJT-R&", gM) this pattern in a string shown below, the only constant is XX. two arguments are random

XX.Xx("$\bH.Pt#S+V0&DJT-R&", gM)
XX.Vx("\'\x40]\tFv9](H\x40J[)", F6)

[XX.Ux("gI\ny", sl), Ar, XX.Rx("\t|", pO), Jd, XX.kx("xW\n", CM), Wm, XX.wx("U\vyV", DO), jr, XX.Mx("U\vxW", GO), Zm, XX.tx("a{O", xO), Hm, XX.RV(Qk, Hl, Q0), Qd, XX.Nx("\t|", OM), Br, XX.zx("{I\v", vM), jd, XX.gx("U\vxS", W6), nm, XX.kV(Qk, UM, Q0), Bd, XX.rx("\t|", RM), Xm, XX.mx("V\r", kM), Id, XX.dx("J\t~", KY), Lm, XX.hx("xV\v", wN), Sd, XX.bx("xU\x00", d6), rd, XX.Cx("axK", BM), Wd, XX.qx("}~", h6), Zd, XX.sx("gI\b", b6), Hd, XX.Kx("xU", C6), Lh, XX.Wx("U\ry", q6), pm["fpValStr"], XX.wV(Qk, Ml, F0), vd, XX.Zx("sH", LN), jm, XX.Hx("{I\f", jM), Xh], Vh && (Wr.push(XX.nx("xT", XN), XX.Ax("", VN)), Th = j3(N3)), Wr.push(XX.Fx("J\nu", nY), Md), Kr = ph(j2, [Wr, A0]), Dh = Wr.join(Kr), qr(XX.Ex("9I\x00", TN).concat(Dh["slice"](N3, W0)));

https://regex101.com/r/Ui71E9/1

lulu33
  • 207
  • 2
  • 10

1 Answers1

2

(XX\.[A-Za-z]*\("([^"]*)",\s*([0-9A-Za-z]{2})\),\s*[0-9A-Za-z)]+)

To capture multiple times

  • run the regexp on the big string
  • if no matches, break
  • use the second and third capture groups as you like
  • get the first capture group
  • in the big string replace that capture group with an empty string
  • do it again with the modified string

Old Answer

XX\.[A-Za-z]*\("(.*)",\s*([0-9A-Za-z]{2})\)

I included capture groups if your interested

I can explain it if you'd like

  • XX\. The beginning is probably obvious. XX\.
    • it's important to note that . in regex matches anything, however I assume you specifically want to get a period. Thus we escape it like \.
  • [A-Za-z]* next we are matching any amount of characters from capital A to capital Z and lower case a and lowercase z. I assume that it will always be 2 characters but I'll let it slide for now
  • \( next we escape the open parenthesis because parenthesis represents a capture group
  • " next we look for a quotation mark
  • (.*)" next we capture anything intil we hit another quotation mark.
    • It's important to note that if the string has an escaped quotation mark, this regexp breaks. If you need an escaped quotation mark also I'll try to help you out
  • , next we look for a comma
  • \s* after that we look for any amount of spaces. Could be zero, could be a hundred
  • (0-9A-Za-z){2} next we capture two characters that could be 0-9 A-Z and A-Z
  • \) finally we end with a parenthesis
formula1
  • 64
  • 5
  • Yes please explain, I added an example that this is embedded it doesn't capture in it – lulu33 Feb 13 '22 at 00:54
  • I'll edit my answer – formula1 Feb 13 '22 at 09:00
  • Thank you I need to match it in here https://regex101.com/r/Ui71E9/1 – lulu33 Feb 13 '22 at 09:10
  • Thanks for the explanation but checkout my link your regex doesn't work when searching in a longer string. Thanks – lulu33 Feb 13 '22 at 09:15
  • https://stackoverflow.com/questions/37003623/how-to-capture-multiple-repeated-groups so it appears you can't capture a single group multiple times. But what you could do is capture the last group then replace it with an empty string. Rinse and repeat until there are no matches left. I plan to update my comment with a new regexp that captures the whole function, the next characters and the individual args – formula1 Feb 13 '22 at 18:21
  • actually, it works I just had to add ? to first capturing group this is the full example `XX\.[A-Za-z]*\("(.*?)",\s*([0-9A-Za-z]{2})\)` – lulu33 Feb 13 '22 at 18:23