top of page

How to check if a text contains certain patterns like email address or URL

💡 Do you know that Microsoft Power Automate for desktop support regular expressions or regex? You can make use of regex for the following actions - Parse Text and Replace Text.

Problem Description


Say you have a text variable containing the following information:

Regular Expression, or regex or regexp in short, is extremely and amazingly powerful in searching and manipulating text strings, particularly in processing text files. One line of regex can easily replace several dozen lines of programming codes. Regex is supported in all the scripting languages (such as Perl, Python, PHP, and JavaScript); as well as general purpose programming languages such as Java; and even word processors such as Word for searching texts. Getting started with regex may not be easy due to its geeky syntax, but it is certainly worth the investment of your time. To learn more, please visit https://werkbook.co.

You want to extract all the URLs contained inside this text. What can you do?

Solution


To extract all the URLs from the text, we can make use of the action Parse text:



Under the parameter Text to find, we will specify the following regular expression:

(?:(?:https?|ftp|file):\\/\\/|www\\.|ftp\\.)(?:\\([-a-zA-Z0-9+&@#\\/%%=~_|$?!:,.]*\\)|[-a-zA-Z0-9+&@#\\/%%=~_|$?!:,.])*(?:\\([-a-zA-Z0-9+&@#\\/%%=~_|$?!:,.]*\\)|[a-zA-Z0-9+&@#\\/%%=~_|$])

Remember to enable the option Is regular expression. In addition, the option First occurence only allows you to specify if you want to find the first match or all of the matches if there are more than 1. In the example, all the found URLs will be stored in the output variable Matches.


💡Pro tip: Use ‘%%’ to escape the special character ‘%’. Alternatively, you can also make use of the action Escape text for regular expression.

Additional Information


  • Last updated on: 9 Feb 2023

  • Tested version(s): 2.27.177.22340

  • Prerequisites: None

  • Dependencies: None

  • Known issues: None

References


  • Nil

Robotic Process Automation Singapore

CFB Bots is a leading technology service provider in the fast-growing field of Intelligent Automation. We partner with large enterprises in their Digital Transformation journey and help them and their employees thrive in the Future of Work.

NAVIGATE
CONTACT US
STAY CONNECTED

Singapore

CFB Bots Pte Ltd

Registration No.: 201705263H

77 High Street

#05-09, High Street Plaza

Singapore 179433

​

T: +65 6909 2099

E: enquiries@cfb-bots.com

​​

Malaysia

CFB Bots Sdn Bhd

Registration No.: 202401045826 (1591672-X)

Suite: 33-01, 33rd Floor

Menara Keck Seng

203 Jalan Bukit Bintang

55100 Kuala Lumpur

​​

T: +60 39 388 0352

E: my@cfb-bots.com

​

Australia

T: +61 2 8880 5998

E: au@cfb-bots.com

Join our mailing list to get the latest insights on automation

  • LinkedIn Social Icon
  • Facebook Social Icon
  • Twitter Social Icon
  • Instagram Social Icon
  • YouTube Social  Icon
TS Master Logo.png

© 2017-2025 CFB Bots Pte Ltd. All Rights Reserved. Tel: (65) 6909 2099 | Email: enquiries@cfb-bots.com | Privacy Policy | Terms of Use

bottom of page