Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Reply
 
Thread Tools Display Modes
Old 04-23-2016, 05:29 PM   #1
ijijn
Human being with feelings
 
ijijn's Avatar
 
Join Date: Apr 2012
Location: Christchurch, New Zealand
Posts: 441
Default JSFX: 'match' not allowing for degenerate @0s at end of string (FIXED)

Okay, so here's the problem:

Code:
desc: String Matching Scenario

@init

#string = "StartMiddleEnd";

match("%0sStart%s", #string, #beforeStart, #middleEnd);
// matches: #beforeStart = "" and #middleEnd = "MiddleEnd"

match("Start%0sMiddle%s", #string, #betweenStartAndMiddle, #end);
// matches: #betweenStartAndMiddle = "" and #end = "End"

match("%sEnd%0s", #string, #startMiddle, #pastEnd);
// doesn't match (but should): no string values assigned
Basically, it seems that %0s at the end of a match string 'needle' won't match a zero-length string in the 'haystack'. My guess is that the matching logic terminates its search efforts prematurely because the end of the string is reached.

As you can see, elsewhere in the string it works as specified.

My workaround is a backup case in the match chain (without the %0s at the end) that forces a "" for #pastEnd. However, this clutters the code unnecessarily and adds another computation into the works, as well as being rather confusing behaviour to debug.

Any chance of fixing this?

Last edited by ijijn; 04-23-2016 at 06:13 PM. Reason: oops, I meant %0s... never mind :D
ijijn is offline   Reply With Quote
Old 04-23-2016, 06:25 PM   #2
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 10,148
Default

Thanks, fixing!
Justin is online now   Reply With Quote
Old 04-23-2016, 06:56 PM   #3
ijijn
Human being with feelings
 
ijijn's Avatar
 
Join Date: Apr 2012
Location: Christchurch, New Zealand
Posts: 441
Default

Quote:
Originally Posted by Justin View Post
Thanks, fixing!
Thanks so much!
ijijn is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:46 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.