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

How would I go about selecting all URL's from a body of text?

I'm getting a GET response that has an element of various text.  There is at least one or more URL's that I'm wanting to extract.  For example,

 

V1: https://ext.somewhere.com
V2: https://ext..somewhere.com\3423rfe\ewfewf32\324234242342

 

 

or some various of the above.  How would I go about removing all the text and keeping just the URL's?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: How would I go about selecting all URL's from a body of text?

Hi @robevans,

 

If there are newlines in the string, you could convert the string into the URI code by using uriComponent() function, then replace the new line ("%0A") to ";", after that, decode it: 

decodeUriComponent(replace(uriComponent(outputs('Compose')),'%0A',';'))

Then use the split() function to separate it into array:

split(outputs('Compose_2'),';')

 Annotation 2020-04-20 133119.png

 

Best Regards,
Community Support Team _ Lin Tu
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

6 REPLIES 6
Highlighted
Dual Super User III
Dual Super User III

Re: How would I go about selecting all URL's from a body of text?

Hi!
The example you shared... what's the expected output?
Thanx!


Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Highlighted
Microsoft
Microsoft

Re: How would I go about selecting all URL's from a body of text?

Sorry the expected output would be just the complete URL and any other text removed.  

 

Highlighted
Dual Super User III
Dual Super User III

Re: How would I go about selecting all URL's from a body of text?

Hi again
Is this the expected output, an array with the following two elements?

https://ext.somewhere.com
and https://ext..somewhere.com\3423rfe\ewfewf32\324234242342
Please note two consecutive dots cannot be part of a valid URL. Also have doubts on \
Thanx!


Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Highlighted
Microsoft
Microsoft

Re: How would I go about selecting all URL's from a body of text?

The two dots are a typo.  An array ideally would be where this would be stored.  I believe the / should be fine because I can dump the entire contents into an array currently.

Highlighted
Dual Super User III
Dual Super User III

Re: How would I go about selecting all URL's from a body of text?

Hi!

Assuming we work with a string variable called 'myInputArray' whose value is...

 

V1: https://ext.somewhere.com
V2: https://ext.somewhere.com\3423rfe\ewfewf32\324234242342

 

 

Also assuming both rows have a new line as separator you can try the following expression:

 

split(variables('myInputString'),'
')

 

Please note I hit Enter to declare my expression

 

So if this approach works you should have an array with two elements

 

[
"V1: https://ext.somewhere.com",
"V2: https://ext.somewhere.com\3423rfe\ewfewf32\324234242342"
]

 

 

You can initialize a second variable, let's call it myOutput Array, type Array, value

 

[]

 

THen assign the above expression as the input of an Apply to Each

 

Now I am assuming the is a single space between V!: V": and the URLs. If so, inside the apply to ech, add a 'Append to array variable' action block, name 'myOuptutArray', assign as its value the following expression:

 

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

 

Now, outside the apply to each, add a dummy action block, assign as its value variable 'myOutputArray'. Execute the flow, inspect its contents, it should look like this:

 

[
"https://ext.somewhere.com",
"https://ext.somewhere.com\3423rfe\ewfewf32\324234242342"
]

 

 

IF you need to convert this output into a string again, you can use join() function

Hope this helps

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Highlighted
Community Support
Community Support

Re: How would I go about selecting all URL's from a body of text?

Hi @robevans,

 

If there are newlines in the string, you could convert the string into the URI code by using uriComponent() function, then replace the new line ("%0A") to ";", after that, decode it: 

decodeUriComponent(replace(uriComponent(outputs('Compose')),'%0A',';'))

Then use the split() function to separate it into array:

split(outputs('Compose_2'),';')

 Annotation 2020-04-20 133119.png

 

Best Regards,
Community Support Team _ Lin Tu
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

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

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