Replace characters in a string

  • Hi,

    I was wondering if anybody can help me figure out how I can replace
    white spaces and possibly carriage return in a string that I have
    from an NSTextView. I need the white spaces to be replaced by "+". In
    the end it will actually be a URL string.

    I was looking at NSMutableString but got stuck.

    Any help highly appreciated.

    Thanks in advance
    Carl
  • Hi Carl-

    If you are producing a URL, I would suggest using NSString's
    stringByReplacingPercentEscapesUsingEncoding: method; it will take
    can of any illegal characters for a URL, including the spaces.

    HTH!

    John

    On Oct 1, 2006, at 8:01 AM, Carl Johan Foss wrote:

    > Hi,
    >
    > I was wondering if anybody can help me figure out how I can replace
    > white spaces and possibly carriage return in a string that I have
    > from an NSTextView. I need the white spaces to be replaced by "+".
    > In the end it will actually be a URL string.
    >
    > I was looking at NSMutableString but got stuck.
    >
    > Any help highly appreciated.
    >
    > Thanks in advance
    > Carl
    >
    >
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/john%
    > 40positivespinmedia.com
    >
    > This email sent to <john...>
  • if not, I suspect NSScanner is a class you'll be rather interested in.

    Mike.

    On 1 Oct 2006, at 15:17, John Pannell wrote:

    > Hi Carl-
    >
    > If you are producing a URL, I would suggest using NSString's
    > stringByReplacingPercentEscapesUsingEncoding: method; it will take
    > can of any illegal characters for a URL, including the spaces.
    >
    > HTH!
    >
    > John
    >
    > On Oct 1, 2006, at 8:01 AM, Carl Johan Foss wrote:
    >
    >> Hi,
    >>
    >> I was wondering if anybody can help me figure out how I can
    >> replace white spaces and possibly carriage return in a string that
    >> I have from an NSTextView. I need the white spaces to be replaced
    >> by "+". In the end it will actually be a URL string.
    >>
    >> I was looking at NSMutableString but got stuck.
    >>
    >> Any help highly appreciated.
    >>
    >> Thanks in advance
    >> Carl
    >>
    >>
    >> _______________________________________________
    >> Do not post admin requests to the list. They will be ignored.
    >> Cocoa-dev mailing list      (<Cocoa-dev...>)
    >> Help/Unsubscribe/Update your Subscription:
    >> http://lists.apple.com/mailman/options/cocoa-dev/john%
    >> 40positivespinmedia.com
    >>
    >> This email sent to <john...>
    >
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/mike.abdullah%
    > 40gmail.com
    >
    > This email sent to <mike.abdullah...>
previous month october 2006 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today