From 43d6e707bb4ebfc47b46440c26997c9d01e32b0b Mon Sep 17 00:00:00 2001 From: mfranz Date: Fri, 22 Jun 2007 20:41:00 +0000 Subject: [PATCH] minus can't be delimiter in a [] range --- Nasal/string.nas | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Nasal/string.nas b/Nasal/string.nas index dd59ecd9b..5461ece20 100644 --- a/Nasal/string.nas +++ b/Nasal/string.nas @@ -65,10 +65,10 @@ var imatch = func(a, b) match(lc(a), lc(b)); # ? stands for any single character # * stands for any number (including zero) of arbitrary characters # \ escapes the next character and makes it stand for itself; that is: -# \? stands for a question mark (not "any single character" placeholder) +# \? stands for a question mark (not the "any single character" placeholder) # [] stands for a group of characters: -# [abc] stands for letters a or b or c -# [^abc] stands for any character but any of a, b, and c +# [abc] stands for letters a, b or c +# [^abc] stands for any character but a, b, and c # [1-4] stands for digits 1 to 4 (1, 2, 3, 4) # [1-4-] stands for digits 1 to 4, and the minus # [-1-4] same as above @@ -77,6 +77,8 @@ var imatch = func(a, b) match(lc(a), lc(b)); # [][] stands for the closing and the opening bracket (']' must be first!) # [^^] stands for all characters but the caret symbol # +# Note that a minus can't be a range delimiter, as in [a--b] +# # Example: # string.match(name, "*[0-9].xml"); ... true if 'name' ends with digit followed by ".xml" # @@ -117,7 +119,8 @@ var match = func(str, patt) { x[patt[p]] = 1; i += 1; - if (p + 2 < patt[p] and patt[p + 1] == `-` and patt[p + 2] != `]`) { + if (p + 2 < patt[p] and patt[p] != `-` and patt[p + 1] == `-` + and patt[p + 2] != `]` and patt[p + 2] != `-`) { var from = patt[p]; var to = patt[p += 2]; for (var c = from; c <= to; c += 1)