Forums / General Questions / what does this regexp means?

what does this regexp means?

Locked

Views: 884

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
11 May 2009, 2:47 AM
#1
laruence avatar

laruence

New Zenner

Join Date:
May 2009
Posts:
4
Plugin Contributions:
0

what does this regexp means?

located in "./admin/includes/application_top.php"
line 121:
$loaderPrefix = preg_replace('/[a-z_]^/', '', $loaderPrefix);

what does this pattern "/[a-z_]^/" means?

spell mistake?

11 May 2009, 3:06 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: what does this regexp means?

No, that's not an error. It's very specific.
It's stripping invalid characters from the passed parameter.
More information on regex: http://www.regular-expressions.info/reference.html
and the PHP preg_replace() function: http://www.php.net/manual/en/function.preg-replace.php

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

11 May 2009, 4:14 AM
#3
laruence avatar

laruence

New Zenner

Join Date:
May 2009
Posts:
4
Plugin Contributions:
0

Re: what does this regexp means?

/[a-z_]^/ this caret means what? thanks

11 May 2009, 4:35 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: what does this regexp means?

In that case, the caret is a negation operator. So, that preg_replace statement replaces any characters not matching a-z or underscore with blanks, effectively removing bad characters.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

11 May 2009, 4:41 AM
#5
laruence avatar

laruence

New Zenner

Join Date:
May 2009
Posts:
4
Plugin Contributions:
0

Re: what does this regexp means?

DrByte:

In that case, the caret is a negation operator. So, that preg_replace statement replaces any characters not matching a-z or underscore with blanks, effectively removing bad characters.

you means [^a-z_] ?

11 May 2009, 4:42 AM
#6
laruence avatar

laruence

New Zenner

Join Date:
May 2009
Posts:
4
Plugin Contributions:
0

Re: what does this regexp means?

var_dump(preg_match('/[a-z_]^/',"A"))

result is false

11 May 2009, 4:43 AM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: what does this regexp means?

Are you running into a particular problem with your store?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.