cateof
cateof

Reputation: 6758

Accept case insensitive prefix in Objective-C

I have a text field that contains an http address. A valid input should be the http:// prefix plus a valid IP address.

I would like to enhance my text field in order to consider valid all strings that have a case insensitive "http" prefix.

For example hTtP://130.14.15.15 is acceptable.

Upvotes: 0

Views: 53

Answers (1)

Cyrille
Cyrille

Reputation: 25144

Instead of testing like if ([aString hasPrefix:@"http://"]) you could test the lowercase version of the string:

if ([aString.lowercaseString hasPrefix:@"http://"])

Upvotes: 2

Related Questions