objective c - RegEx for creating hashtag text -
i'm writing iphone can create various tags. tag's format should like this:
#a-z
where first character of tag #, while charaters after # between a-z , a-z. explain how write regex, , if possible how i'd implement nsstring's?
edit:
here's how you'd implement nsstring , nspredicate:
nsstring *hashtagregex = @"#[a-za-z]+"; nspredicate *hashtagtest = [nspredicate predicatewithformat:@"self matches %@", hashtagregex]; if ([hashtagtest evaluatewithobject:textfield.text] == no) { // not valid hashtag }
use regular expression:
#[a-za-z]+
Comments
Post a Comment