Gossamer Forum
Home : General : Perl Programming :

N e w regex issue

Quote Reply
N e w regex issue
   
I have difficulty to understand below regex ,
any senior here could help me understand
access =~ m/($cat|GLOB)::|admin/i; ## what's this mean?


Thanks in advance


if ($private eq "Yes") {
my @staff = support::Staff->load({notify=>1});
while ( my $s = shift @staff ) {
next unless $s->access =~ m/($cat|GLOB)::|admin/i;
next if $s->username eq $q->cookie('staff');
my $ref = $s->columns;
my $name = $ref->{'name'};
chomp($recipient = $ref->{'email'});
my $hdtime = time();
my $msg .= "There is a new help desk response made by a staff member:\n";
$msg .= "\nCall Details\n";
$msg .= "---------------------------------------\n";
$msg .= "\t Response by......: $name\n";
$msg .= "\t Time.............: $hdtime\n";
$msg .= "\t Ticket...........: $trackno\n";
$msg .= "\t Comments.........: $comments\n";
$msg .= "---------------------------------------\n";
$msg .= "\n\nThank You.";
$self->email(
To => $recipient,
From => $global{adminemail},
Subject => " (STAFF MESSAGE)",
Body => $msg )
}
}
Quote Reply
Re: [courierb] N e w regex issue In reply to
It means the value of $s->access must contain a substring either matching GLOB::admin or whatever the value of $cat is plus ::admin.

The string may be mixed case too.

eg...

GLOB::Admin
GLOB::admin
Quote Reply
Re: [Orbital] N e w regex issue In reply to
Hi Orbital,Thanks you very much.

actually this script is not working now. as the string format now is
category1:: category2:: category3:: GLOB:: (case 1 contain GLOB)
admin (case 2 contain admin)
category1:: category2 :: category3:: category4 (case 3 contain category1)
category3:: GLOB:: (case 4 contain glob)
category2:: category3:: (case 5 )

*(case5 is not met my needs)

what i need is :
the value of $s->access must contain a substring either matching
GLOB or Admin or Category1 , how do i make it? (case5 is not met my needs)


Thanks
Quote Reply
Re: [courierb] N e w regex issue In reply to
Oops actually I missed the | in the regex so what it actually matches is a substring like:

$cat::
GLOB::

-OR-

admin


I'm not too clear on your requirements for the new regex, perhaps you could expand a little?
Quote Reply
Re: [Orbital] N e w regex issue In reply to
If that is the case, the regex works for me.

i do not quite understand regex. so look for help here.
below code should be the same as above in regex handling.

$statement = 'SELECT * FROM table WHERE access LIKE "%' . "$cat" . '::%" OR access LIKE "%GLOB::%" OR access="admin" AND username != "' . "$Cookies{'staff'}" . '"';


what is this condition meaning?
username != "' . "$Cookies{'staff'}" . '"

weather it means username should not be the value of staff stored in cookie?

Thank you
Quote Reply
Re: [courierb] N e w regex issue In reply to
Quote:
weather it means username should not be the value of staff stored in cookie?

Correct.

The regex should be ok for your requirements.