It is currently May 17th, 2024, 1:47 am

[Bug] Regex: last capture is optional+empty = no substring

Report bugs with the Rainmeter application and suggest features.
User avatar
killall-q
Posts: 305
Joined: August 14th, 2009, 8:04 am

[Bug] Regex: last capture is optional+empty = no substring

Post by killall-q »

If the last capture is optional and empty (when you are on the latest comic), this error is logged for [mNext]:

WebParser: Not enough substrings

Code: Select all

[mSite]
Measure=Plugin
Plugin=WebParser
URL=http://comic.skullkickers.com/
RegExp=(?sU)src="comics/../comics/(.*)".*rel="start".*id=(\d*)".*id=(\d*)#.*(?:id=(\d*)".*)?</div>
StringIndex=3
DynamicVariables=1
FinishAction=[!SetOption mSite URL http://comic.skullkickers.com/index.php?id=#*Num*#][!SetVariable Num [mSite]]

[mNext]
Measure=Plugin
Plugin=WebParser
URL=[mSite]
StringIndex=4
This error does not occur for optional captures that are followed by non-empty captures. So the current workaround is to add a dummy 5th capture.

Code: Select all

RegExp=(?sU)src="comics/../comics/(.*)".*rel="start".*id=(\d*)".*id=(\d*)#.*(?:id=(\d*)".*)?</d(i)
Code excerpted from my webcomic viewer.