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

Remove text which is in double quotes in a string

I have an issue with power automate flow. I have an string where I want to remove any text which is in double quotes and replace it with blanc value.

Example: This is a string "with" blabla.

Change in to: This is a string blabla.

I have tried to use replace function but failed because I don't know the regex. This doesn't work

 

replace('This is a string "with" blabla.','"?*','')

tried to with replace('This is a string "with" blabla.','/(".+?")/gm','')

this to don't work

Thank you for help

1 ACCEPTED SOLUTION

Accepted Solutions
Paulie78
Super User III
Super User III

Hi, 

 

You can do it like this:

https://youtu.be/NyTjqKzvthg

 

The code from the video is:

function main(
  workbook: ExcelScript.Workbook,
  stringToSearch: string, 
  pattern: string, 
  replaceString? :string
) {
  if (typeof (replaceString) === 'undefined') {
    replaceString = '';
  }
  var re = new RegExp(pattern, "gm");
  let cleanStr: string = stringToSearch.replace(re, replaceString);
  console.log(cleanStr);
  return cleanStr;
}

Let me know if you get stuck.

View solution in original post

5 REPLIES 5
Paulie78
Super User III
Super User III

There is no regex support, which is a real shame. So you cannot do what you are trying to do in the way that you are trying to do it.

 

It is possible to do, but not with a single regex replace like you want to do.

Paulie78
Super User III
Super User III

Do you still need to do this? I have a way of doing it.

Hi Paulie78

Yes please share your idea;)

Thank you

Paulie78
Super User III
Super User III

Hi, 

 

You can do it like this:

https://youtu.be/NyTjqKzvthg

 

The code from the video is:

function main(
  workbook: ExcelScript.Workbook,
  stringToSearch: string, 
  pattern: string, 
  replaceString? :string
) {
  if (typeof (replaceString) === 'undefined') {
    replaceString = '';
  }
  var re = new RegExp(pattern, "gm");
  let cleanStr: string = stringToSearch.replace(re, replaceString);
  console.log(cleanStr);
  return cleanStr;
}

Let me know if you get stuck.

View solution in original post

Thank you Paulie78 I the meantime I did the same in Excel script 😉 But I have used regex because there is working 😉

Same idea 😉

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors
Users online (2,149)