Page 1 of 2

[FIXED BUG] RegEx not being parsed correctly with Substitute.

Posted: October 10th, 2017, 12:46 pm
by redsaph
Hello,

I use the following RegEx statement to trim down the title of a song and use the first capture group

Code: Select all

\1
in order to do it:

Code: Select all

^(.+) (-.+|((\(|\[)?\s?(remix|Remix|REMIX|with|With|WITH|feat|Feat|FEAT|ft|Ft|FT|(w|W)\/).+))+$
Now, I took Kendrick Lamar's song Loyalty which is titled as

Code: Select all

LOYALTY. FEAT. RIHANNA.
This should return

Code: Select all

LOYALTY.
Why this isn't working for RegExpSubtitute and Subtitute when various online testers and RainRegExp verify it works?

Re: RegEx not being parsed correctly with Substitute?

Posted: October 10th, 2017, 1:28 pm
by balala
I think something is not ok with the posted regular expression: it has mor opened parenthesis then closed ones.
But first, please post the whole code. It'd be much simpler to help.

Re: RegEx not being parsed correctly with Substitute?

Posted: October 10th, 2017, 2:32 pm
by ikarus1969
balala wrote:I think something is not ok with the posted regular expression: it has mor opened parenthesis then closed ones.
That's because one of the open parenthesis is escaped with the backslash character.

@redsaph:
what i would try is to replace the regular expression by:

Code: Select all

(?siU)^(.+) (-.+|((\(|\[)?\s?(remix|with|feat|ft|w\/).+))+$
which would simplify it a little bit.
the i in (?siU) means "ignore case" so you don't have to code all the possible different cases like "remix" "REMIX", etc.

it work's in RainRegExp too.

But i agree with balala; it would be much easier to help with the code of the whole skin. Or at least a test skin we can have a look at.

Re: RegEx not being parsed correctly with Substitute?

Posted: October 10th, 2017, 2:39 pm
by redsaph
Hi guys, thanks for the quick response. Here's the simple example, maybe you could see it too:

Code: Select all

[Rainmeter]
Update=50
Author=Redsaph
AccurateText=1

[mTitle1]
Measure=Plugin
Plugin=SpotifyPlugin.dll
Type=TrackName
RegExpSubstitute=1
Substitute="^(.+) (-.+|((\(|\[)?\s?(remix|Remix|REMIX|with|With|WITH|feat|Feat|FEAT|ft|Ft|FT|(w|W)\/).+))+$":"\1"

; =================================================
; Meters

[Background]
Meter=Image
X=0
Y=0
W=700
H=100
SolidColor=0,0,0,180
UpdateDivider=-1

[Title]
Meter=String
Y=0
X=0
DynamicVariables=1
Text=[mTitle1]
FontFace=Segoe UI
FontSize=36
FontColor=255,255,255,255
AntiAlias=1
StringAlign=Left
@ikarus1969 Thank you very much for simplifying my RegEx :) I didn't know that existed!

Re: RegEx not being parsed correctly with Substitute?

Posted: October 10th, 2017, 2:57 pm
by ikarus1969
I admit i have no idea why your regexp doesn't work :confused:
Maybe someone else can help?!

Re: RegEx not being parsed correctly with Substitute?

Posted: October 10th, 2017, 6:15 pm
by balala
I agree with ikarus1969 and also don't know what's happening, why that Substitute option doesn't work. A regular expression tester indeed returned the appropriate string, so, I have no idea what's happening... :o
But I'd suggest another substitution: Substitute="(?siU)^(.*)\s*(remix|with|feat|ft)\.\s*(.*)$":"\1". As ikarus1969 said, there's no need to list all those words, written uppercase and lowercase and so on. The (?siU) can help in these cases.

Re: RegEx not being parsed correctly with Substitute.

Posted: October 11th, 2017, 4:14 am
by redsaph
Thanks Ikarus and Balala! I hope someone from the development team can shed some light on this issue.

Re: [BUG] RegEx not being parsed correctly with Substitute.

Posted: October 11th, 2017, 4:44 am
by Brian
The problem stems from a fix we did back in the r2414 or r2416 builds. We are evaluating a fix and will get back to you. Rainmeter versions prior to r2414 worked okay (for this particular issue).

-Brian

Re: [BUG] RegEx not being parsed correctly with Substitute.

Posted: October 12th, 2017, 4:00 pm
by Brian
r2944 should have fixed this issue.

-Brian

Re: [BUG] RegEx not being parsed correctly with Substitute.

Posted: October 13th, 2017, 9:24 am
by ikarus1969
Brian wrote:r2944 should have fixed this issue.

-Brian
this issue is fixed, thank you!

i used the following to test (shortened regex):

Code: Select all

[Rainmeter]
Update=1000
Author=Redsaph
AccurateText=1

; [mTitle1]
; Measure=Plugin
; Plugin=SpotifyPlugin.dll
; Type=TrackName
; RegExpSubstitute=1
; Substitute="^(.+) (-.+|((\(|\[)?\s?(remix|Remix|REMIX|with|With|WITH|feat|Feat|FEAT|ft|Ft|FT|(w|W)\/).+))+$":"\1"

[mTitle1]
Measure=STRING
String=LOYALTY. FEAT. RIHANNA.
RegExpSubstitute=1
; Substitute="^(.+) (-.+|((\(|\[)?\s?(remix|Remix|REMIX|with|With|WITH|feat|Feat|FEAT|ft|Ft|FT|(w|W)\/).+))+$":"\1"
Substitute="(?siU)^(.+) (-.+|((\(|\[)?\s?(remix|with|feat|ft|w\/).+))+$":"\1"

; =================================================
; Meters

[Background]
Meter=Image
X=0
Y=0
W=700
H=100
SolidColor=0,0,0,180
UpdateDivider=-1

[Title]
Meter=String
Y=0
X=0
DynamicVariables=1
measurename=mTitle1
; Text=[mTitle1]
FontFace=Segoe UI
FontSize=36
FontColor=255,255,255,255
AntiAlias=1
StringAlign=Left