Hi Guys,
In the following line:
cn=portal.090710.191533.428571000,cn=groups,dc=mp, dc=rj,dc=gov,dc=br
I need to extract this string: portal.090710.191533.428571000
As you can see this string always will be bettween "cn=" and "," strings.
Someone know one regular expression to extract this string?
Any help will be very much appreciated
Best Regards
Pierre
|
Banned
|
|
| 20Aug2009,10:47 | #2 |
|
MyString = "1234567890"
startPos = 3 charCount = 4 Print Mid$(MyString,startPos,charCount) ' Prints "3456" |
|
Banned
|
|
| 20Aug2009,10:48 | #3 |
|
Similarly,
cn=portal.090710.191533.428571000,cn=groups,dc=mp, dc=rj,dc=gov,dc=br startPos = 4 charCount = 33 Print Mid$(MyString,startPos,charCount) |
|
Newbie Member
|
|
| 20Aug2009,23:12 | #4 |
|
Hi naimish,
I don´t understand your idea... I have the following code: if( /cn=/ ) { $result = $_; $result =~ s/^cn=([^,]*?),//; <-- MY REGEX EXPRESSION } return $result in this case your REGEX is returning cn=groups,dc=mp,dc=rj,dc=gov,dc=br I need the opposite result. I think a REGEX where in the first time remove the string cn= so the result string will be portal.090710.191533.428571000,cn=groups,dc=mp,dc= rj,dc=gov,dc=br The second REGEX will remove the entire string cn=groups,dc=mp,dc=rj,dc=gov,dc=br To be lefting only the needed string portal.090710.191533.428571000 Can you help me? Regards Pierre |
|
Newbie Member
|
|
| 10Oct2009,05:11 | #5 |
|
You could try something like:
@res = ($line =~ /cn=(.*?),/ig) print $res[0]; |
|
Team Leader
|
![]() |
| 27Oct2009,17:28 | #6 |
|
Code: Perl
Last edited by pradeep; 27Oct2009 at 17:28.. Reason: Code block |
|
Newbie Member
|
|
| 24Feb2010,13:53 | #7 |
|
my $str="cn=portal.090710.191533.428571000,cn=groups, dc=mp, dc=rj,dc=gov,dc=br";
if($str=~/cn=(.*),cn=/) { print $1; } |
|
Light Poster
|
|
| 3Aug2011,16:45 | #8 |
|
$a='cn=portal.090710.191533.428571000,cn=groups,dc =mp, dc=rj,dc=gov,dc=br';
$a=~ /p[\w.]*/; print"$&\n"; |

