in reply to Substr Perl

If the wanted string will always be preceded by "CN=ext.Group.", you can use the following regular expression:
for my $string ('CN=ext.Group.eso,OU=External,OU=ExDistriGroups,OU=Acc +ounts,DC=eso,DC=local', 'CN=ext.Group.test,OU=External,OU=ExDistriGroups,OU=Ac +counts,DC=eso,DC=local', 'CN=ext.Group."MY TERM",OU=External,OU=ExDistriGroups, +OU=Accounts,DC=eso,DC=local', ) { my ($term) = $string =~ /CN=ext\.Group\.([^,]+)/; print "Found: $term\n"; }

See perlre and perlop for details.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Substr Perl
by mba777 (Novice) on Nov 26, 2013 at 11:58 UTC
    thats exactly what i need, but how does it work if the list of "CN=...." is an array?

      Can you give us an example of what such a record would look like?

      It helps to remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.
        sorry for my stupid questions but i'm actually no programmer ;), For example i have something like that:
        my @member = $entry->get_value ('memberOf'); my @memberof = grep(/\CN=ext\.Group\.([^,]+)/,@member); $member = join(',',@memberof); print "$uid -- $member\n";
        This code gives me the following output: Michael Douglas -- CN=ext.Group.eso,OU=External,OU=ExDistriGroups,OU=Accounts,DC=eso,DC=local,CN=ext.Group.test,OU=External,OU=ExDistriGroups,OU=Accounts,DC=eso,DC=local,CN=ext.Group.test1,OU=External,OU=ExDistriGroups,OU=Accounts,DC=eso,DC=local,CN=ext.Group.test2,OU=External,OU=ExDistriGroups,OU=Accounts,DC=eso,DC=local What i want is: Michael Douglas -- eso, test, test1, test2 Thanks Andy