- Declared In:
- NSString+misc.h
String matchingReplacement in between delimeters
- - rangeBetweenString:andString:
- - rangeBetweenString:andString:options:
- - rangeBetweenString:andString:options:range:
- - rangeFromString:toString:
- - rangeFromString:toString:options:
- - rangeFromString:toString:options:range:
XML processing
- - replaceAllTextBetweenString:andString:fromDictionary:options:range:
- - replaceAllTextBetweenString:andString:fromDictionary:options:
- - replaceAllTextBetweenString:andString:fromDictionary:
Other string utilities
- - xmlEscapedString
- - unescapeXML
- - flattenHTML
- - urlDecode
- - urlEncode
- - encodeLegally
- - stripQuotes
- - hyperlink
- - digitsOnly
- - condenseWhiteSpace
- - trimWhiteSpace
- - removeWhiteSpace
- - crunchWhiteSpace
- - checksum
- - lossyASCIIString
- - floatVersion
- - componentsSeparatedByLineSeparators
- (int)checksum
Return a checksum of the string, calculated by adding the Unicode value of each character in the string into an integer total, ignoring overflow.
- (NSArray *)componentsSeparatedByLineSeparators
Split a string into lines separated by any of the various newline characters. Equivalent to componentsSeparatedByString:@"\n" but it works with the different line separators: \r, \n, \r\n, 0x2028, 0x2029
- (NSString *)condenseWhiteSpace
Return a string where runs of multiple white space characters (space, tab, all types of newline, return, forced space, and Unicode U+FFFC, Object replacement character) are condensed down to a single space. Trim off any leading/trailing white space.
- (NSString *)crunchWhiteSpace
Return a string where runs of multiple white space characters (space, tab, all types of newline, return, forced space, and Unicode U+FFFC, Object replacement character) are condensed down to a single one of those character.
- (NSString *)digitsOnly
Return a string consisting only of the digits in the string. For example, (916) 692-1560 is converted to 9166921560.
- (NSString *)encodeLegally
Fix a URL-encoded string that may have some characters that makes NSURL barf. It basicaly re-encodes the string, but ignores escape characters + and %, and also #.
- (NSString *)flattenHTML
Remove HTML tags to turn a fragment of HTML into a piece of plain text. All characters between < and > are removed. Escape sequences such as & are converted into their character equivalents.
- (float)floatVersion
Take out all but the first decimal point, and turn into a floating number. This isn't going to do well with numbers >=10 between the decimal points 1.0 -> 1.0 1.1 -> 1.1 1.1.1 -> 1.11 1.2.3.4 -> 1.234 but 1.10 -> 1.1 and 1.1 -> 1.1 ! etc.
- (NSAttributedString *)hyperlink
Convert the given string into an attributed string with attributes resembling a hypertext link, blue with underline.
- (NSString *)lossyASCIIString
Convert a string to its ASCII equivalent, lossily.
- (NSRange)rangeBetweenString:(NSString *)inString1 andString:(NSString *)inString2
Find a string between the two given strings with the default options; the delimeter strings are not included in the result.
- (NSRange)rangeBetweenString:(NSString *)inString1 andString:(NSString *)inString2 options:(unsigned)inMask
Find a string between the two given strings with the given options inMask; the delimeter strings are not included in the result. The inMask parameter is the same as is passed to [NSString rangeOfString:options:range:].
- (NSRange)rangeBetweenString:(NSString *)inString1 andString:(NSString *)inString2 options:(unsigned)inMask range:(NSRange)inSearchRange
Find a string between the two given strings with the given options inMask and the given substring range inSearchRange; the delimeter strings are not included in the result. The inMask parameter is the same as is passed to [NSString rangeOfString:options:range:].
- (NSRange)rangeFromString:(NSString *)inString1 toString:(NSString *)inString2
Find a string from one string to another with the default options; the delimeter strings are included in the result.
- (NSRange)rangeFromString:(NSString *)inString1 toString:(NSString *)inString2 options:(unsigned)inMask
Find a string from one string to another with the given options inMask; the delimeter strings are included in the result. The inMask parameter is the same as is passed to [NSString rangeOfString:options:range:].
- (NSRange)rangeFromString:(NSString *)inString1 toString:(NSString *)inString2 options:(unsigned)inMask range:(NSRange)inSearchRange
Find a string from one string to another with the given options inMask and the given substring range inSearchRange; the delimeter strings are included in the result. The inMask parameter is the same as is passed to [NSString rangeOfString:options:range:].
- (NSString *)removeWhiteSpace
Remove all white space from a string.
- (NSString *)replaceAllTextBetweenString:(NSString *)inString1 andString:(NSString *)inString2 fromDictionary:(NSDictionary *)inDict
Find a string between the two given strings with the default options; the delimeter strings are not included in the result.
- (NSString *)replaceAllTextBetweenString:(NSString *)inString1 andString:(NSString *)inString2 fromDictionary:(NSDictionary *)inDict options:(unsigned)inMask
Find a string between the two given strings with the given options inMask; the delimeter strings are not included in the result. The inMask parameter is the same as is passed to [NSString rangeOfString:options:range:].
- (NSString *)replaceAllTextBetweenString:(NSString *)inString1 andString:(NSString *)inString2 fromDictionary:(NSDictionary *)inDict options:(unsigned)inMask range:(NSRange)inSearchRange
General search-and-replace mechanism to convert text between the given delimeters. Pass in a dictionary with the keys of "from" strings, and the values of what to convert them to. If not found in the dictionary, the text will just be removed. If the dictionary passed in is nil, then the string between the delimeters will put in the place of the whole range; this could be used to just strip out the delimeters.
- (NSString *)stripQuotes
Remove any leading and trailing double-quote marks and return the resulting string.
- (NSString *)trimWhiteSpace
Return the string with all white space (space, tab, all types of newline, return, forced space, and Unicode U+FFFC, Object replacement character) trimmed from the start and end of the string.
- (NSString *)unescapeXML
Convert XML with escaped characters into a regular string
- (NSString *)urlDecode
Convert a URL-encoded string into a plain string, changing + into space, and nn sequences into corresponding character. This is used to convert text found in a URL line into human-readable.
- (NSString *)urlEncode
Convert a plain string into a new string, replacing certain characters with the equivalent percent escape sequence.
- (NSString *)xmlEscapedString
Convert > = >, etc. into their counterparts.