• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How can replace widestring to other widestring?

Enthusiast ,
Jun 02, 2021 Jun 02, 2021

Copy link to clipboard

Copied

How can replace widestring to other widestring?

WideString strContent=WideString("this is <a/> and <a/> is data");

WideString strValue=WideString("ABC");

I want replace tag <a/> to  text "ABC";

 

I see sdk doc has replace function, but not exist find function :

WideString & replace (const WideString::const_iterator &b, const WideString::const_iterator &e, const WideString &s)

How can find const_iterator start, end?

 

TOPICS
SDK

Views

168

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 02, 2021 Jun 02, 2021

Hi @daitranthanhoa,

You can create the iterator explicitly using its constructor. See the sample code below, it should work I could not test it

    WideString strContent=WideString("this is <a/> and <a/> is data");
    WideString strValue=WideString("ABC");
    int32 a = strContent.IndexOf(WideString("<a/>"));
    while(a >= 0)
    {
        strContent.replace(WideString::const_iterator(&strContent, a), WideString::const_iterator(&strContent, a + 4), strValue);
        a = strContent.IndexOf(Wid
...

Votes

Translate

Translate
Community Expert ,
Jun 02, 2021 Jun 02, 2021

Copy link to clipboard

Copied

LATEST

Hi @daitranthanhoa,

You can create the iterator explicitly using its constructor. See the sample code below, it should work I could not test it

    WideString strContent=WideString("this is <a/> and <a/> is data");
    WideString strValue=WideString("ABC");
    int32 a = strContent.IndexOf(WideString("<a/>"));
    while(a >= 0)
    {
        strContent.replace(WideString::const_iterator(&strContent, a), WideString::const_iterator(&strContent, a + 4), strValue);
        a = strContent.IndexOf(WideString("<a/>"));
    }

 -Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines