Skip to main content
Nintex Community Menu Bar
Solved

Extract Regex group

  • Aug 1, 2022 1:31 PM UTC
  • 2 replies
  • 66 views
  • Translate All

Hi,

 

im trying to extract a substring from a LDAP query output, but I cant figure out how I can extract just the content of the group.

My pattern looks like this:
`CN=(.*?),OU=*.?Department`

The date im running it on looks like this, there are a few more lines like this with different names and departments:
`CN=Firstname Lastname,OU=Department,OU=Company,DC=Company,DC=local`

 

The data i wish to get is `Firstname Lastname`.

Best answer by Garrett

Hi @mwalk 

Here is one possible solution.

 

String (string is without quotes, right?)

`CN=Firstname Lastname,OU=Department,OU=Company,DC=Company,DC=local`

 

Regex - Extract 

(CN=[w|s]*),(OU=[w|s]*)

Result: 'CN=Firstname Lastname,OU=Department'

 

Regex - Extract 

(CN=[w|s]*)

Result: 'CN=Firstname Lastname'

 

If you just wanted 'Firstname Lastname', you need a second Regex to replace the 'CN=' with '' (blank or empty chars) 

 

Cheers

 

View original

2 replies

Garrett
Forum|alt.badge.img+16
  • Scout
  • Answer
  • Aug 1, 2022 2:49 PM UTC

Hi @mwalk 

Here is one possible solution.

 

String (string is without quotes, right?)

`CN=Firstname Lastname,OU=Department,OU=Company,DC=Company,DC=local`

 

Regex - Extract 

(CN=[w|s]*),(OU=[w|s]*)

Result: 'CN=Firstname Lastname,OU=Department'

 

Regex - Extract 

(CN=[w|s]*)

Result: 'CN=Firstname Lastname'

 

If you just wanted 'Firstname Lastname', you need a second Regex to replace the 'CN=' with '' (blank or empty chars) 

 

Cheers

 

Translate

  • Author
  • Aug 2, 2022 7:41 AM UTC
Yes, that works. Thanks a lot!
Translate