Cri*_*pto 1 objective-c ios nsregularexpression
我有以下格式的文件名
filename_ffffff.png
filename2_cccccc.png
...
Run Code Online (Sandbox Code Playgroud)
如何操作此字符串并将其十六进制值替换为我选择的值.
说新的价值是fffccc什么,filename_ffffff.png并把它变成filename_fffccc.png
-(NSString *)replace:(NSString *)input with:(NSString *)newHex{
//find in input a patern of 6 char hex followed by dot png
// remove it from the string
// add the newHex followed by png
}
Run Code Online (Sandbox Code Playgroud)
-(NSString *)replace:(NSString *)input with:(NSString *)newHex
{
NSArray *seperated = [input componentsSeparatedByString:@"_"];
return [NSString stringWithFormat:@"%@_%@.png", [seperated objectAtIndex:0], newHex];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
121 次 |
| 最近记录: |