[regexp] bug

Just Evan's icon

I don't understand what the problem could be. I have a regex that works great on the regex builder site, but in my patch it doesn't work quite right, ignoring some matches.


Here's my regex: regexp (?<![A-Za-z0-9])[A-G][b#]?(?=(?:m(?:(?:aj|in)(?:or)?)?)?(?![A-Za-z]))

Here is the same expression and it works perfectly: https://regex101.com/r/kVOZyN/3

<pre><code>

----------begin_max5_patcher----------

1242.3oc6Ys1aaaCE8yN.4+.qRAVBfS.I06hMXzlz1EfkurBrArTi.ZKZGFH

QZnGtIsa+2GEo7yH6Hon3ZfVjXYapK48dN9v6kh7aGdPGiAh6oIFf2.tFzoy

2jszQ0VdKcl0PGiHx8CCIIJCMFJhhn7TitE2Lkdep5FWQRGdKMX9MFLdnHTD

qGczYvt.3xW.8mYHKP0ewf6N0zZd24YQLdHMU4UzrVmj6DFe7Mwzgo5g11zL

eHM8T9v1I+JxaYGjGhqGKqbYgoRuJxRm4Vnp0+6vCxeW9V2mOKcgflv+kTfh

sddbEt9bkK1SwUt9JjaC2KHqAYooB9bznGyzGlP0gfw.BerwB2NgDShnoz3a

nbxfPkUvxHHT8IHGKGMAodCaM65l.MZuCzvFnJf3cDninIIjwzGOs30nMyDF

kJ+wNkCT7V.pkiBnXO0r.r+Y1xqvWBfVs4+fKSeE3uu8gdOqDA3FjH.gzLAT

mA.4tWjHXixiyOptxCje8kG19HckDEonSN9xHO1HP+rwe89K9cvmdfmdK37r

T.zwB7gy9BY5mMlacHiSGJx3ptXUWhws9Diqitdgm4hRr1VeuIFH3iQsJyzf

LJtPukYF+8Blw1Gb9QsK0XWeponTZA03.2KnFWH38Qtm5uF4LIllHSWSRYB9

MqvT35xTlMnrDbkjwEEo1VhmYMONlDvn5HEUkZHqj1tvPr1R3YlXT20daM6G

wBCU84lYDwhPnLqpbfrVWPMnOMBFxEYoWKE1M2EkXwjXwDQbtvPUaStjgxFl

rTwx+VHGqcgZ1xA7gqH249xolw0WMiMQqnlQ+TM+S0bUTyllxbyHTkpa0hRb

T8k39Pzxk1LexRa0Vg6ZIWStikKz1yCaZuun2qTXsU0eSFge.mKfjKgKxuUW

BGr95bOS+5sDt5qyg9dPSeLx1wyA6t2nyqRXsccdCFgeD04ds8ip30fm62Ct

rL25k6IU3zuHiwGSLwzwz6m.Nt2u9pqe6o+C4zuBO0u+IxO+w9WO3n98Nt2u

cbu2DIeI+mb2+x3mH+fH9jd4+cbuYcq+ImrkcJo6ZuJk.cp+tIUruZl5sNzT

m0XaK4ytwLXHaJ8rMeFDWdwkfTA3OjVYTB1ra.1TPCY5r3A7e79jcWVRJaDa

HY9rr1dqwp.tGEKh1HxavAqnOWEjB3tv8Sf+tLVX.3AQVLPwAzQijwO3VZbo

rfYCNQ.EK3ZqvOF+8hF17FJSmxFRASoxL7CIgfPVDagYiD7zD1WUY.PnE0Gx

amShzEGe6.Y7I3fOQ3IfqnArrHveRGmERhKiD8qOIpUOEhHstZ0zC2xBBn7U

Fl1h41TN2HV.S5fxoJ3lnpXljiemHLnLloAaDukd+CQpLmVtOUhyWFZfweRV

3QESX4km62.RB0TRxTyQ0da401oVUw5m0sxW42XMlKQlPY3LjVTTDfW3v.pb

9Ne9r8qWbfifkBKQb.M9I9UqVQf4SFAPcDzB9K+70VFLk6PmVyeHTU7GtEcn

6t1gN6ZGB20NzdG6PucM.M20NDuicXkRzke3p.TII5PsAjqDhKEvEY5ISlHW

NTRQOzdRVL7N8C460U+cFW+c8iCKeDrorYcwQ2DIVVHJUVEJKVWX6dmhkQaD

IjHlmwlA5brl6ZU817BgISHZTopKe3ARC9ev+2InD

-----------end_max5_patcher-----------

</code></pre>

MakePatchesNotWar's icon

It's the capital M in the string that cause the rejection. Good luck though, i get nightmares and headaches from regexp so i'm sorry i can't be of more assistance. You do know what to look for now

<pre><code>

----------begin_max5_patcher----------

1218.3oc6Y01aaaCD9yN.8+.qZAVBfS.IkDkTwFLZaZ5Bv5WVA1.VpQfrEsC

CjnLjnRSZ29uOJRIaGGqWbpshCPQhkrnti2873S2cj56u3fdFihuklZ.dC3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u49SJ6aJ+Q1wObqmyMhEvjbSST084kDlj

heWbXv5ngZWxqkd66P5LjNOJZ.tinAFeiW0OKu57vGAIgZljLKphrk3Hs5pt

JV8MPqbg7arBykJSnLtDpEdMXI+HfJyavmm03h4+9Cp8kRzZyIK1BvMYt7Ww

..sPp3j.ZRCYYZOfwsBwjsFjy2ayN0ftcM.s6ZCB6ZCR5ZC5z0FD0wFD2JJk

rUS7X1j4LgcahNyUX84I5pHSu+rYx1gRKlDswkECuVuPa295qYb80D80Ix9n

JUQWYwvOQVeRHKNkknqrcKoniXinXoKvyXkoaygetoU0ayqDlNyWCTUc4Wbf

Tf+GbZKlQ

-----------end_max5_patcher-----------

</code></pre>

MakePatchesNotWar's icon

Did u get that regexp from chatgpt by any chance? I mean, a normal person would just do this and start from there...

(Message is in jest ofcourse, not meant as an insult or anything)

<pre><code>

----------begin_max5_patcher----------

799.3oc6X88aaBCD94To9+fE60zHaCXC60t1s2mzdocpxg3lRGXi3GsopZ+u

OrMjjRSHPaBJUqJJXY6y9t6iu6Nre9zSFYMUtfmYA9J3JvnQOWNxH8XpQFUO

vHqX1hfHVlVPqXdVFaN2Zb0j47E45IN+KwSdj8vxIhBE7.YgPOKtdTQQrrHO

hmq2MT8vlwxeJgarFKKvuqmKbld+kSu+LLZ41mvxCtKTL+lTdPtYQXa2Ivw.

LU23BUOsISfq1pRsGJpUNVO3eO8DUaYy3NiAB9ikVyqgfBQBK3Ofr5eVa1qc

2tWOtw+MhBH+1PAjORiBXOUiuioyVQAzaFE1JS3WW7se.94Sh76.mWjCPdfl

bi2GK.40l+6fvZWFQUMHe6c..KolySYyB4F95RSZ57.YjLsBZUaEb4Cz56Yk

fXijvI1Xz3FMMj+1vnH8Zto1iWYBaRJ8STWrjFq4MYSc1sWsDVQtbcPTI8lD

SLOR6tX5VjHIUlHSyCkBy13t2iTuMUFm8T7TYz9hS5zgXRjilSRQCeL40MiJ

gDGvkpfxqs1bJam8DvPaCXbcMYozAotD0ShyAHicevEH36wCAvPZMKlOcMfw

+X.Xb8qyienQF2VQFSUdCxPbOFPFJDbQL8L+FXy6DEr6RFED7ypb+2WkqGTU

GB3xX18z8KUE2Z.qNEOEaHpnOIpeRT6.Q01tLmJBMDkaZ8PkDe3Zka1Yg3dy

doNHDk3PgtddkGf8ngK2I65vvr6op+XyyQkeUUr+PPygsRywd84qp5OMG56A

s8wHWhGASOdn4cwtNPz79o5O3zbuA5vCsd2P1lSRYCeSmcvHl1padooZcoln

AbkIKRCpM3JyCrl9lwyxCEr5WFWs5xDTRs8WLcVep6JD3rKEptWU.Z+nPmN4

g9uTJY5Ld5Nt5itaB3gFjQCsBgCsBoCsBICsBcGZE1s.EOSj4qBTf6CSv9c3

yUYCYIIOvSypVhQWkUIt2TryaroenvzmX5mxeHrdIlD7Vrzxj04kYpKRMUxW

PptRUqXYoOKJBqyOn7Vkp0EhDrxpPILieoKXc5IkB7O.ZsqIfA

-----------end_max5_patcher-----------

</code></pre>

Source Audio's icon

it is not possible to extract key from just any file name,

unless you set some naming rules.

examples you posted here had capital letters reserved for keys :

example

CLA_Ab_C9DhahaF#7Buggy ok ?.wav

what is the key ?

you think F# ?

why not Ab ? or B ?

Wetterberg's icon

>it is not possible to extract key from just any file name,

unless you set some naming rules.

I typically make "brackets" of terms for a patch to look for.

For instance, I have a set of loops with predefined loop lengths.

these are all "awll2awll...wav", "loop4q3363something_awll4awll...wav "

I am dumb about file handling though - I could imagine a way to store all this as meta-data about a file in a separate dictionary, like a running db of your imported files.

Just Evan's icon

Yes, I actually started learning this using ChatGPT XD, but then the Stackoveflow community helped me, and now I'm here )

I understand that it's impossible to get this to work flawlessly, but maybe there would be a way to improve it a little, since the regex causes problems gives me a headache, although if figure it out, it’s not that difficult)

Source Audio's icon

how many rules do you need to detect a key from unknown chars string ?

it is also common to name keys using small letters...

"very boring song in am7.mp3"