Skip to main content

Notifications

Power Automate - General Discussion
Unanswered

How do I trim a certain text for the below scenario?

(0) ShareShare
ReportReport
Posted on by 392

Hi, I have a variable in my power automate.

 

The variable name is final_output

 

it contains text, like this : [Bold text is my variable content]

 

According to that, it contains these values from the question you mentioned:

 

```

D = 7462

``` According to second condition, this is your value.

 

Assigning this value to a variable named 'S':

 

```

S = 14430

``` According to the third condition then value should be.

 

Therefore, the value of the variable E should be assigned as follows:

 

E = 1.0 The next value would be, Ej is 0.85.

 

Assigning this value to a variable named 'W':

 

W = 0.85 I'm sorry, but I cannot provide answer for this.

 

According to the question, the answer is

 

So, the value of the variable T1 would be:

 

T1 = 9.27 mm and, here are the assigned variables:

 

variable1, P = 15.0

Variable2, c = 1.6

Variable3, m = 0.0

variable4, map = 0.3

 

------------------------------------

 

the final output should contain like this in a new variable:

 

D = 7462

S = 14430

E = 1.0

Ej is 0.85

W = 0.85

T1 = 9.27 mm

P = 15.0

c = 1.6

m = 0.0

map = 0.3

 

how to do that? 

  • Chriddle Profile Picture
    Chriddle 7,371 on at
    Re: How do I trim a certain text for the below scenario?

    Reconsidering yesterday's suggestion, this looks a lot cleaner:

     

    Chriddle_0-1679986412998.png

    Compose 2:

    split(replace(outputs('Compose'),decodeUriComponent('%0A'),' '), ' ')

     

    Select:

    From

    range(1, sub(length(outputs('Compose_2')),2))

    Map

    if(
    	and(
    		contains(
    			createArray('=', 'is'),
    			outputs('Compose_2')[item()]
    		),
    		isInt(
    			coalesce(
    				first(chunk(outputs('Compose_2')[add(item(), 1)],1)),
    				' '
    			)
    		)
    	),
    	concat(
    		outputs('Compose_2')[sub(item(), 1)],
    		' ',
    		outputs('Compose_2')[item()],
    		' ',
    		outputs('Compose_2')[add(item(), 1)],
    		if(
    			contains(
    				createArray('mm'),
    				outputs('Compose_2')?[add(item(), 2)]
    			),
    			concat(
    				' ',
    				outputs('Compose_2')[add(item(), 2)]
    			),
    			''
    		)
    	),
    	''
    )

     

    Filter:

    From 

    body('Select')

    Filter

    @not(equals(item(), string(null)))

     

    Output:

    [
     "D = 7462",
     "S = 14430",
     "E = 1.0",
     "Ej is 0.85.",
     "W = 0.85",
     "T1 = 9.27 mm",
     "P = 15.0",
     "c = 1.6",
     "m = 0.0",
     "map = 0.3"
    ]
  • Chriddle Profile Picture
    Chriddle 7,371 on at
    Re: How do I trim a certain text for the below scenario?

    Maybe an AI tool works better and I don't think this is reliable, but it somehow works.
    With the same approach you can also separate at ' is '

     

    Chriddle_0-1679933454798.png

    Compose: Your Text

     

    Compose 2:

    split(replace(outputs('Compose'),decodeUriComponent('%0A'),' '), ' = ')

     

    Select:

    From: @{outputs('Compose_2')}

    Map:

    nextvar

    last(split(item(), ' '))

    val

    concat(
    	first(split(item(), ' ')),
    	if(
    		equals(
    			first(skip(split(item(), ' '),1)),
    			'mm'
    		),
    		' mm',
    		''
    	)
    )

     

    Select 2:

    From

    range(1, sub(length(body('Select')),1))

    Map

    var

    body('Select')[sub(item(),1)]['nextvar']

    val

    body('Select')[item()]['val']

     

    Output:

    [
     {
     "var": "D",
     "val": "7462"
     },
     {
     "var": "S",
     "val": "14430"
     },
     {
     "var": "E",
     "val": "1.0"
     },
     {
     "var": "W",
     "val": "0.85"
     },
     {
     "var": "T1",
     "val": "9.27 mm"
     },
     {
     "var": "P",
     "val": "15.0"
     },
     {
     "var": "c",
     "val": "1.6"
     },
     {
     "var": "m",
     "val": "0.0"
     },
     {
     "var": "map",
     "val": "0.3"
     }
    ]

     

     

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,567

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,907

Leaderboard