Home > Net >  REGEX: only use 1 line to delete everything except what is between "=" and the first "
REGEX: only use 1 line to delete everything except what is between "=" and the first "

Time:03-31

In asterisk we get the following string from the AD:

"CN=lastname firstname,OU=internal,OU=UserAccounts,OU=bussiness,DC=bussiness,DC=bussiness,DC=be"

I only need "lastname firstname" so I would like to use REGEX to cut away:

  • everything before and including the "="
  • everything behind and including the first ","

Is this possible?

Kind regards,

CodePudding user response:

You can use this Regex:

(?<=CN=)[^,] 

You can replace CN by any field to get its value.

Try it here

  • Related