Don Wilson
Don Wilson

Reputation: 2303

Wildcards in strings

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 there a way I can use wildcards to get the desired result?

Upvotes: 2

Views: 622

Answers (3)

Mike Abdullah
Mike Abdullah

Reputation: 15003

Use NSNumberFormatter configured to the right pattern.

Upvotes: 0

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

Upvotes: 1

YOU
YOU

Reputation: 123881

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

Upvotes: 6

Related Questions