Need help for regex

Hello,

i need to get specific value from below text -
E:\apps2_s2_rpa\FactoryINDUSAPPS2\iPLAN\User Addition-License Activation>dsquery * domainroot -filter “(&(objectCategory=User)(sAMAccountName=“kmathkar”))” -attr cn
cn
kmathkar

E:\apps2_s2_rpa\FactoryINDUSAPPS2\iPLAN\User Addition-License Activation>

i need outpt - kmathkar

what regex should i use to get this value?
kmathkar will change but place remai same.
help me with regex

Hello

How about this pattern?
(?<=sAMAccountName=.)[a-zA-Z0-9]+

Use the following with an assign:
System.Text.RegularExpression.Regex.Match(yourString, “(?<=sAMAccountName=.)[a-zA-Z0-9]+”).ToString

Cheers

Steve

This one i need.

Hi

Try this:
Option 1
(?<=cn[\s]+cn[\s]+).*

Option 2
Pattern:
(?<=cn[\s]+).*(?=[\s]+[A-Z].)

Option 3
Pattern: .*(?=[\s]+[A-Z]:\\)

Cheers

Steve

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.