NSString(FWApplication)
@interface NSString (FWApplication)
#pragma mark - Pinyin
/**
* 中文转拼音并进行比较
*
* @param string 中文字符串
*/
- (NSComparisonResult)fw_pinyinCompare:(NSString *)string NS_REFINED_FOR_SWIFT;
#pragma mark - Regex
/**
* 安全截取字符串。解决末尾半个Emoji问题(半个Emoji调UTF8String为NULL,导致MD5签名等失败)
*
* @param index 目标索引
*/
- (NSString *)fw_emojiSubstring:(NSUInteger)index NS_REFINED_FOR_SWIFT;
/**
* 正则搜索子串
*
* @param regex 正则表达式
*/
- (nullable NSString *)fw_regexSubstring:(NSString *)regex NS_REFINED_FOR_SWIFT;
/**
* 正则替换字符串
*
* @param regex 正则表达式
* @param string 替换模板,如"头部$1中部$2尾部"
*
* @return 替换后的字符串
*/
- (NSString *)fw_regexReplace:(NSString *)regex withString:(NSString *)string NS_REFINED_FOR_SWIFT;
/**
* 正则匹配回调
*
* @param regex 正则表达式
* @param block 回调句柄。range从大至小,方便replace
*/
- (void)fw_regexMatches:(NSString *)regex withBlock:(void (^)(NSRange range))block NS_REFINED_FOR_SWIFT;
#pragma mark - Html
/**
转义Html,如"a<"转义为"a<"
@return 转义后的字符串
*/
@property (nonatomic, copy, readonly) NSString *fw_escapeHtml NS_REFINED_FOR_SWIFT;
// 创建一个UUID字符串,示例:"D1178E50-2A4D-4F1F-9BD3-F6AAB00E06B1"。也可调用NSUUID.UUID.UUIDString
@property (class, nonatomic, copy, readonly) NSString *fw_UUIDString NS_REFINED_FOR_SWIFT;
@end
Undocumented
-
中文转拼音并进行比较
Declaration
Objective-C
- (NSComparisonResult)fw_pinyinCompare:(nonnull NSString *)string;
Parameters
string
中文字符串
-
安全截取字符串。解决末尾半个Emoji问题(半个Emoji调UTF8String为NULL,导致MD5签名等失败)
Declaration
Objective-C
- (nonnull NSString *)fw_emojiSubstring:(NSUInteger)index;
Parameters
index
目标索引
-
正则搜索子串
Declaration
Objective-C
- (nullable NSString *)fw_regexSubstring:(nonnull NSString *)regex;
Parameters
regex
正则表达式
-
正则替换字符串
Declaration
Objective-C
- (nonnull NSString *)fw_regexReplace:(nonnull NSString *)regex withString:(nonnull NSString *)string;
Parameters
regex
正则表达式
string
替换模板,如"头部$1中部$2尾部“
Return Value
替换后的字符串
-
正则匹配回调
Declaration
Objective-C
- (void)fw_regexMatches:(nonnull NSString *)regex withBlock:(nonnull void (^)(NSRange))block;
Parameters
regex
正则表达式
block
回调句柄。range从大至小,方便replace
-
转义Html,如"a<“转义为"a<”
Declaration
Objective-C
@property (nonatomic, copy, readonly) NS_REFINED_FOR_SWIFT NSString *fw_escapeHtml;
Return Value
转义后的字符串
-
Undocumented
Declaration
Objective-C
@property (class, nonatomic, copy, readonly) NSString *fw_UUIDString