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

Report bugs with the Rainmeter application and suggest features.
User avatar

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

October 10th, 2017, 12:46 pm
redsaph
   [25 posts]

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?
Last edited by redsaph on October 13th, 2017, 10:14 am, edited 3 times in total.
User avatar

Re: RegEx not being parsed correctly with Substitute?

October 10th, 2017, 1:28 pm
balala
Rainmeter Sage   [4734 posts]

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.
User avatar

Re: RegEx not being parsed correctly with Substitute?

October 10th, 2017, 2:32 pm
ikarus1969
   [227 posts]

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.
User avatar

Re: RegEx not being parsed correctly with Substitute?

October 10th, 2017, 2:39 pm
redsaph
   [25 posts]

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!
User avatar

Re: RegEx not being parsed correctly with Substitute?

October 10th, 2017, 2:57 pm
ikarus1969
   [227 posts]

I admit i have no idea why your regexp doesn't work :confused:
Maybe someone else can help?!
User avatar

Re: RegEx not being parsed correctly with Substitute?

October 10th, 2017, 6:15 pm
balala
Rainmeter Sage   [4734 posts]

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.
User avatar

Re: RegEx not being parsed correctly with Substitute.

October 11th, 2017, 4:14 am
redsaph
   [25 posts]

Thanks Ikarus and Balala! I hope someone from the development team can shed some light on this issue.
User avatar

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

October 11th, 2017, 4:44 am
Brian
Developer   [1556 posts]

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
User avatar

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

October 12th, 2017, 4:00 pm
Brian
Developer   [1556 posts]

r2944 should have fixed this issue.

-Brian
User avatar

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

October 13th, 2017, 9:24 am
ikarus1969
   [227 posts]

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

Return to “Bugs & Feature Suggestions”



Who is online

Users browsing this forum: No registered users and 4 guests