Remove only first instance of a character from a list of characters

Posted by Luke on Stack Overflow See other posts from Stack Overflow or by Luke
Published on 2010-05-29T07:29:04Z Indexed on 2010/05/29 7:32 UTC
Read the original article Hit count: 193

Filed under:
|
|

Hi All,

Here's what I want to do. I have 2 strings and I want to determine if one string is a permutation of another. I was thinking to simply remove the characters from string A from string B to determine if any characters are left. If no, then it passes.

However, I need to make sure that only 1 instance of each letter is removed (not all occurrences) unless there are multiple letters in the word.

An example:

String A: cant

String B: connect

Result: -o-nec-

Experimenting with NSString and NSScanner has yielded no results so far.

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about cocoa