How can I detect if a string contains punctuation marks at the end?

Posted by Sheehan Alam on Stack Overflow See other posts from Stack Overflow or by Sheehan Alam
Published on 2010-04-22T17:07:34Z Indexed on 2010/04/22 17:33 UTC
Read the original article Hit count: 194

Lets assume I have the string:

"Hello I like your shoes #today...!"

I am tokenizing the string by spaces:

return [string componentsSeparatedByString:@" "];

So my array contains:

Hello
I
like
your
shoes
#today...!

I want to focus on "#today...!" any word that has a # in the prefix I am changing the font color.

How can I make sure that only "#today" has its font color changed?

I would basically like to figure out if a word has a punctuation mark at the end, and change the color for characters before the punctuation mark.

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about nsstring