From ec6c08e9ea1f901e1affbeefa3963b997f412cd2 Mon Sep 17 00:00:00 2001 From: vijaykiran Date: Tue, 16 Sep 2008 18:40:15 +0200 Subject: [PATCH] Fixed [CPString boolvalue] method with RegExps --- Foundation/CPString.j | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Foundation/CPString.j b/Foundation/CPString.j index e70459789..06cc03895 100644 --- a/Foundation/CPString.j +++ b/Foundation/CPString.j @@ -135,7 +135,8 @@ var CPStringHashes = new objj_dictionary(); } /* - Creates a new string using C printf-style formatting. First argument should be a constant format string, like ' "float val = %f" ', remaining arguments should be the variables to print the values of, comma-separated. + Creates a new string using C printf-style formatting. First argument should be a constant format string, + like ' "float val = %f" ', remaining arguments should be the variables to print the values of, comma-separated. @param format the format to be used, printf-style @return the initialized CPString */ @@ -174,6 +175,7 @@ var CPStringHashes = new objj_dictionary(); } // Combining strings + /* Creates a new CPString from the concatenation of the receiver and the specified string. @param aString the string to append to the receiver @@ -459,18 +461,16 @@ CPNumericSearch { return eval(self); } - /* -Returns YES on encountering one of "Y", "y", "T", "t", or -a digit 1-9. Returns NO otherwise. This method skips the initial -whitespace characters, +,- followed by Zeroes. + Returns YES on encountering one of "Y", "y", "T", "t", or + a digit 1-9. Returns NO otherwise. This method skips the initial + whitespace characters, +,- followed by Zeroes. */ + - (BOOL)boolValue { - var aString = self.replace(/^\s+[\+,-]*0*/,""); - if (aString.match(/[Y,y,t,T,[1-9]/) != null) - return YES; - return NO; + var replaceRegExp = new RegExp("^\\s*[\\+,\\-]*0*"); + return RegExp("^[Y,y,t,T,1-9]").test(self.replace(replaceRegExp, '')); } /*