cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

How to use Substitute() on special character like " and '

Here I want to substute site address in every <img> tag <img src="/Test/Test.jpg" alt="" />

so I use

Substitute(ThisItem.Instructions,"<img src=","<img src='https://powerTest.sharepoint.com")

But here it breaks a URL by adding extra "

Result: <img src="https://powerTest.sharepoint.com"/Test/Test.jpg" alt="" />

 

So images are not render in Htmltext control.  If anyone have idea please suggest how to do this?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: How to use Substitute() on special character like " and '

Hi @HirenKataria,

Based on the needs that you mentioned, I agree with @NEPatton's thought almost. I think the Char() function could achieve your needs.

On your side, please modify your Substitude formula as below:

Substitute(
ThisItem.Instructions,
"<img src="&Char(39),
"<img src="& Char(39) &"https://powerTest.sharepoint.com"
)

More details about the Char() function in PowerApps, please check the following article:

Char function

More details about ASCII characters supported within your platform, please check the following article:

http://www.asciitable.com/

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Power Apps
Power Apps

Re: How to use Substitute() on special character like " and '

You can use the following expression:

Substitute(
    ThisItem.Instructions,
    "<img src=""",
    "<img src=""https://powertest.sharepoint.com")

This will search for the (") character (to enter a double quote in a string you need to "double it"), and replace it with another one.

Highlighted
Kudo Kingpin
Kudo Kingpin

Re: How to use Substitute() on special character like " and '


@CarlosFigueira wrote:

You can use the following expression:

Substitute(
    ThisItem.Instructions,
    "<img src=""",
    "<img src=""https://powertest.sharepoint.com")

This will search for the (") character (to enter a double quote in a string you need to "double it"), and replace it with another one.


Yeah - the root of the issue here is that you were searching/replacing

<img src=

but you really wanted to be searching for

<img src="

 

You can follow @CarlosFigueira's method, or you can use the Char() function.  The Char() function can sometimes look clunky, but I often prefer it because there are fewer questions about what's happening.  Char(34) = "  It's equivalent to write Char(34) as it is to write "".  Using this function, your solution could also look like this:

 

Substitute(
    ThisItem.Instructions,
    "<img src="&char(34),
    "<img src=""https://powertest.sharepoint.com")

 Or, alternatively....

Substitute(
    ThisItem.Instructions,
    "<img src="&char(34),
    "<img src="&char(34)&"https://powertest.sharepoint.com")

 

So again -- it looks clunky, but if you're comfortable with using functions like this -- it could be argued that there is less ambiguity here.  2 ways to get the same thing, pick your preference and good luck!

Highlighted
Community Support
Community Support

Re: How to use Substitute() on special character like " and '

Hi @HirenKataria,

Based on the needs that you mentioned, I agree with @NEPatton's thought almost. I think the Char() function could achieve your needs.

On your side, please modify your Substitude formula as below:

Substitute(
ThisItem.Instructions,
"<img src="&Char(39),
"<img src="& Char(39) &"https://powerTest.sharepoint.com"
)

More details about the Char() function in PowerApps, please check the following article:

Char function

More details about ASCII characters supported within your platform, please check the following article:

http://www.asciitable.com/

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Frequent Visitor

Re: How to use Substitute() on special character like " and '

 

Helpful resources

Announcements
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,301)