i'm not quite good using regex and spend two days try to fixing this problem and of course searching solutions in stackoverflow but nothing solve my problem. and here's the problem.
score variable will increased by 1 using this code
@inc score
we capture the variable using this regex
inc: /^@inc (.*)$/
and this is the argument
if (match.inc) {
section = this.addAttribute(match.inc[1] + '+=1', story, section, passage, isFirst, inputFilename, lineCount);
}
then i try to advanced it a little more to be like this
@inc score 15
and i alter the regex
inc: /^@inc (.*)( )(.\d*)$/
and that code work fine with this alteration
if (match.inc) {
section = this.addAttribute(match.inc[1] + '+=' + match.inc[3], story, section, passage, isFirst, inputFilename, lineCount);
}
my question is, how the regex should be? if i want keep both working
@inc score <----- will increase by 1
@inc score 100000 <----- will increase by number
and of course how the argument should be?
here's the actual code link line 197 and line 299
sorry for my bad english, not my mother language