开发者

Wildcards in strings

开发者 https://www.devze.com 2022-12-16 21:42 出处:网络
I\'m interested in using rangeOfString with some wildcard characters as part of a search string. For example, if I have several strings like \"244px\" and \"356px\" and I want to convert all such str

I'm interested in using rangeOfString with some wildcard characters as part of a search string.

For example, if I have several strings like "244px" and "356px" and I want to convert all such strings to "320px". Is开发者_JS百科 there a way I can use wildcards to get the desired result?


If you could use regex, you can do substitution for this pattern "[1-9][0-9]+px" to "320px"


RegexKitLite is what you want, it has a small NSString extenstion class that lets you use the built-in regex libraries easily.


Use NSNumberFormatter configured to the right pattern.

0

精彩评论

暂无评论...
验证码 换一张
取 消