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

73

Likes

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

Adobe Community Professional , 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...

Likes

Translate

Translate
Adobe Community Professional ,
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

Likes

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