Skip to main content
Nintex Community Menu Bar
Solved

Regular Expression to extract URL from text string

  • November 9, 2022
  • 2 replies
  • 1370 views

bobFermi
Forum|alt.badge.img+2

Hello All,

 

I need to extract URL(s) from a text string using the regex function.  A sample string may be something like: "This is a test https:||yahoo.com this is still a test"  (I had to replace the // with || to be able to post a URL)

 

I found a regex expression online that works great when I test it with a regex tester online, however the Nintex regex action returns nothing.  Why would this regex expression work on a regex tester but not for nintex?

 

 

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

 

Best answer by MegaJerk

It might not be working for you because of the enclosing regex brackets and tokens at the end: 

/.../igm

 

If I format it without those opening and closing brackets / tokens:

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

 

And instead configure the Regex Workflow Action to ignore case:

 

Then I get a working match extraction:

 

Let me know if this solves the issue for you!

 

PS: Remember that you'll need to assign a Collection type Workflow Variable to the output of your Regex Extraction! It will output ALL matches to their own index in the Collection!

 

 

2 replies

MegaJerk
Forum|alt.badge.img+14
  • Scholar
  • Answer
  • November 10, 2022

It might not be working for you because of the enclosing regex brackets and tokens at the end: 

/.../igm

 

If I format it without those opening and closing brackets / tokens:

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

 

And instead configure the Regex Workflow Action to ignore case:

 

Then I get a working match extraction:

 

Let me know if this solves the issue for you!

 

PS: Remember that you'll need to assign a Collection type Workflow Variable to the output of your Regex Extraction! It will output ALL matches to their own index in the Collection!

 

 


  • November 12, 2022

Using RegexBuddy:

To Get URL only:

.*(?=/)/

 

To Get Filename only:

(?<=/)[^/?#]+(?=[^/]*$)

 

Test String:

This is a URL with a filename https://yahoo.com/gtip/foo.mmmhttps://yahoo.com/gtip/foo.pdf