So if I have "7A7F6E88920AB8271A"
and I want to split it into an array of strings with same amount of character count, like "7A", "7F", "6E", "88", ...
is there any method ready for this, or I have to manually make it on objective C? Thanks.
所以,如果我有“7A7F6E88920AB8271A”并且我想把它拆分成具有相同字符数量的字符串数组,如“7A”,“7F”,“6E”,“88”,......是否有任何方法准备好了为此,还是我必须在目标C上手动制作它?谢谢。
1 个解决方案
#1
1
I am not an objective-c expert, but the following might lead you in the right direction (Regular Expressions)
我不是客观的专家,但以下内容可能会引导您朝着正确的方向前进(正则表达式)
NSRegularExpression regexp = [NSRegularExpression
regularExpressionWithPattern:@"(\\w){2}"
options:NSRegularExpressionCaseInsensitive error:&error];
NSArray *matches = [regex matchesInString:string options:0
range:NSMakeRange(0, [string length])];
The RegExp (\\w){2}
should find all 2-length character words and each of them are in the matches array.
RegExp(\\ w){2}应该找到所有2个长度的字符单词,并且每个单词都在matches数组中。
Constructed from examples on this page: https://developer.apple.com/reference/foundation/nsregularexpression
根据此页面上的示例构建:https://developer.apple.com/reference/foundation/nsregularexpression
#1
1
I am not an objective-c expert, but the following might lead you in the right direction (Regular Expressions)
我不是客观的专家,但以下内容可能会引导您朝着正确的方向前进(正则表达式)
NSRegularExpression regexp = [NSRegularExpression
regularExpressionWithPattern:@"(\\w){2}"
options:NSRegularExpressionCaseInsensitive error:&error];
NSArray *matches = [regex matchesInString:string options:0
range:NSMakeRange(0, [string length])];
The RegExp (\\w){2}
should find all 2-length character words and each of them are in the matches array.
RegExp(\\ w){2}应该找到所有2个长度的字符单词,并且每个单词都在matches数组中。
Constructed from examples on this page: https://developer.apple.com/reference/foundation/nsregularexpression
根据此页面上的示例构建:https://developer.apple.com/reference/foundation/nsregularexpression