It is currently March 28th, 2024, 9:48 am

string splitting

Get help with creating, editing & fixing problems with skins
Post Reply
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: string splitting

Post by jsmorley »

Code: Select all

[Variables]
MyString=Luis Fonsi - Despacito

[MeasureLeft]
Measure=String
String=#MyString#
RegExpSubstitute=1
Substitute="^(.*) - .*$":"\1"

[MeasureRight]
Measure=String
String=#MyString#
RegExpSubstitute=1
Substitute="^.* - (.*)$":"\1"
1.png
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5380
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: string splitting

Post by eclectic-tech »

You would need to a FinishAction on the webparser to use a new measure with an IfMatch test, to see if a hyphen is in [MeasureRainmeter].

Code: Select all

[MeasureRainmeter]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1
Url="#URL#"
RegExp=(?siU)<title>(.*) - YouTube</title>
Substitute="[":"","]":"","lyric":"","(lyric)":"","(":"","Official":"","Music":""," Video":"",")":""
DecodeCharacterReference=3
StringIndex=1
DynamicVariables=1
FinishAction=[!UpdateMeasure Test4Hyphen]

[Test4Hyphen]
Measure=String
String=[MeasureRainmeter]
IfMatch=^.* - .*$
IfMatchAction=[!HideMeter MeterLastUpdate][!ShowMeter MeterLastUpdateHyphen]
IfNotMatchAction=[!ShowMeter MeterLastUpdate][!HideMeter MeterLastUpdateHyphen]

[MeasureLeft]
Measure=String
String=[MeasureRainmeter]
RegExpSubstitute=1
Substitute="^(.*) - .*$":"\1"

[MeasureRight]
Measure=String
String=[MeasureRainmeter]
RegExpSubstitute=1
Substitute="^.* - (.*)$":"\1"
Then if there is a hyphen, you have choices to either change the MeasureName(s) options in your title string meter to use the "Left" and "Right" regexpsubstitute values and change the Text value to show 2 measures...

Or hide the normal title meter and show a hyphen title meter in the same location; something like this:.

Code: Select all

[MeterLastUpdate]
Meter=STRING
MeasureName=MeasureRainmeter
X=110
Y=r
StringAlign=Center
StringEffect=none
StringStyle=Bold
StringCase=Upper
Padding=15,5,15,5
FontColor=255,255,255
FontSize=8
FontFace=Segoe UI
Antialias=1
Text=%1
hidden=1
DynamicVariables=1

[MeterLastUpdateHyphen]
Meter=STRING
MeasureName=MeasureLeft
MeasureName2=MeasureRight
X=110
Y=r
StringAlign=Center
StringEffect=none
StringStyle=Bold
StringCase=Upper
Padding=15,5,15,5
FontColor=255,255,255
FontSize=8
FontFace=Segoe UI
Antialias=1
Text=%1
hidden=1
DynamicVariables=1
You may need to modify this since you already have [MeterLastUpdate] hidden, and apparently show it by some other test. You didn't post the #URL#, so I can't fully test.
Post Reply