aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPStringAdditions.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/SPStringAdditions.m')
-rw-r--r--Source/SPStringAdditions.m41
1 files changed, 3 insertions, 38 deletions
diff --git a/Source/SPStringAdditions.m b/Source/SPStringAdditions.m
index bc9e99fe..18f62b0b 100644
--- a/Source/SPStringAdditions.m
+++ b/Source/SPStringAdditions.m
@@ -153,22 +153,7 @@
// -------------------------------------------------------------------------------
- (NSString *)backtickQuotedString
{
- // mutableCopy automatically retains the returned string, so don't forget to release it later...
- NSMutableString *workingCopy = [self mutableCopy];
-
- // First double all backticks in the string to escape them
- // I don't want to use "stringByReplacingOccurrencesOfString:withString:" because it's only available in 10.5
- [workingCopy replaceOccurrencesOfString: @"`"
- withString: @"``"
- options: NSLiteralSearch
- range: NSMakeRange(0, [workingCopy length]) ];
-
- // Add the quotes around the string
- NSString *quotedString = [NSString stringWithFormat: @"`%@`", workingCopy];
-
- [workingCopy release];
-
- return quotedString;
+ return [NSString stringWithFormat: @"`%@`", [self stringByReplacingOccurrencesOfString:@"`" withString:@"``"]];
}
// -------------------------------------------------------------------------------
@@ -180,32 +165,12 @@
// -------------------------------------------------------------------------------
- (NSString *)tickQuotedString
{
- // mutableCopy automatically retains the returned string, so don't forget to release it later...
- NSMutableString *workingCopy = [self mutableCopy];
-
- // First double all backticks in the string to escape them
- // I don't want to use "stringByReplacingOccurrencesOfString:withString:" because it's only available in 10.5
- [workingCopy replaceOccurrencesOfString: @"'"
- withString: @"''"
- options: NSLiteralSearch
- range: NSMakeRange(0, [workingCopy length]) ];
-
- // Add the quotes around the string
- NSString *quotedString = [NSString stringWithFormat: @"'%@'", workingCopy];
-
- [workingCopy release];
-
- return quotedString;
+ return [NSString stringWithFormat: @"'%@'", [self stringByReplacingOccurrencesOfString:@"'" withString:@"''"]];
}
- (NSString *)replaceUnderscoreWithSpace
{
- NSMutableString *workingCopy = [self mutableCopy];
- [workingCopy replaceOccurrencesOfString:@"_"
- withString:@" "
- options:NSLiteralSearch
- range:NSMakeRange(0, [workingCopy length])];
- return [workingCopy autorelease];
+ return [self stringByReplacingOccurrencesOfString:@"_" withString:@" "];
}
// -------------------------------------------------------------------------------