web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / My string contains an (
Power Automate
Answered

My string contains an (

(0) ShareShare
ReportReport
Posted on by 60

I have a filename as a string containing among other things "1 (Old" or "2 (Old".   The length and structure of the string may change so I can't use split or substring.

 

In my fx I have:

If( contains( outputs('Compose'), '1 (Old', '1',

If( contains( outputs('Compose'), '2 (Old', '2',

''))

 

It's part of a much bigger line of code finding various bits of the string using contains, every other bit is working fine but this part is failing, I assume because there is an open bracket in the string.

Any advice?  Thanks

Categories:
I have the same question (0)
  • Verified answer
    mahoneypat Profile Picture
    1,720 on at

    Can you use the replace() function before this step to replace the (s with a unique character?

     

    Pat

  • Ellis Karim Profile Picture
    11,793 Super User 2025 Season 2 on at

    I think what may be happening here is that the second if statement is missing the false condition?

    Try:

    if(contains(outputs('Compose'),'1 (Old'),1,if(contains(outputs('Compose'),'2 (Old'),2,'NO MATCH!'))

    The if condition requires: If(condition, true, false)

     

    Ellis

  • RobH1 Profile Picture
    60 on at

    Hi,  It's not that, it has a false condition, it's just blank with ''.  You are correct though I am missing the ) from my code after (Old' should be (Old') but it still fails.

  • RobH1 Profile Picture
    60 on at

    Thanks, I had thought of that after posting but wanted to avoid it as both ( ) occur throughout the string so I have to replace both with unique characters and re write everything but that and adding the missing ) to my code does work.

    Just seems odd that it wouldn't ignore the ( when it is wrapped in '' making it part of the string and I wondered if I was missing something.

    Final code now looks like:
    Compose = replace( replace( substring( items('Apply_to_each')?['{Name}'],8),'(','^'),')','^')

    fx to extract the bit I want =

    If( contains( outputs('Compose'), '1 ^Old'),'1', If( contains( outputs('Compose'), '2 ^Old'),'2','')


     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
trice602 Profile Picture

trice602 398 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 323 Super User 2025 Season 2

#3
Expiscornovus Profile Picture

Expiscornovus 183 Most Valuable Professional

Last 30 days Overall leaderboard