×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    46

    Find and Replace a string in HBufc

    Hi ,

    I have a HBufC* which contains for ex "hi iam fine"
    I want to find "hi" in that string and replace it with "HI"

    How can I do that.
    Please help me

    Thanks in advance,
    Prathibha.

  2. #2
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143

    Re: Find and Replace a string in HBufc

    have you tried using Des() fucntion on the HBufC, and then using the Find() funciton provided by the TPtrC.

  3. #3
    Registered User
    Join Date
    Dec 2007
    Location
    India
    Posts
    26

    Re: Find and Replace a string in HBufc

    Hi Partiba Try this

    HBufC* iBuf;
    iBuf->Des()->Find()
    Satish Khatri

  4. #4
    Registered User
    Join Date
    Feb 2010
    Posts
    46

    Re: Find and Replace a string in HBufc

    My statement is as follows
    hbuf->Des()->Find(str);
    but its giving an error : a pointer /array type was expected

  5. #5
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143

    Re: Find and Replace a string in HBufc

    the des() is not returning pointer, thus do not use ->

  6. #6
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,956

    Re: Find and Replace a string in HBufc

    how about this:

    TPtr iptr(iBuf->Des());

    TInt iPosition = iptr.Find(_L("your char"));

  7. #7
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143

    Re: Find and Replace a string in HBufc

    howabout having it in one line

    Code:
    TInt iPosition = iBuf->Des().Find(_L("your char"));

  8. #8
    Registered User
    Join Date
    Feb 2010
    Posts
    46

    Re: Find and Replace a string in HBufc

    yeah , Thank you

  9. #9
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,567

    Re: Find and Replace a string in HBufc

    Code:
    _LIT(KHi,"hi");
    TInt pos=iBuf->Find(KHi);
    searching for text does not require a modifiable descriptor.

Similar Threads

  1. find and replace string
    By kuddy_abc in forum Symbian C++
    Replies: 1
    Last Post: 2010-05-30, 08:42
  2. String search and replace
    By Zilppuri in forum Symbian C++
    Replies: 4
    Last Post: 2009-05-08, 19:41
  3. How to raplace a sub string in HBufC
    By truonglekhanh_hcmuns in forum Symbian C++
    Replies: 2
    Last Post: 2007-07-05, 14:12
  4. Replace a placeholder in _LIT with a string?
    By kaiten-sushi in forum Symbian C++
    Replies: 7
    Last Post: 2007-01-29, 15:23
  5. How can i compare HBufC string?
    By seera in forum Symbian C++
    Replies: 5
    Last Post: 2006-09-12, 09:13

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •