Jump to content

[SOLVED] Preg_match variables of a certain pattern


newbtophp

Recommended Posts

Im trying to create a preg_match to match variables, which are always 38 characters long and always start with $SPLPF followed by random letters and numbers all uppercase.

 

Example variables:

 

$SPLPFMA7E07CE476A248553FE6D996A078C08

 

$SPLPFF3ACA209490CBA3B3F38DC9C1DA910TC

 

All help is greatly apreciated  :-\

I meant how would i integrate that variable regex to another regex pattern:

 

like:

 

'/echo\("hey"\);.*^\$SPLPF[A-Z0-9]{32}$/';

 

would placing the variable like that work?

 

also.

 

if(preg_match('#^\$SPLPF[A-Z0-9]{32}$#', $file)) {

echo "match";

}

 

Only seems to work if $file contains just the variable and no other code, is their any modifiers i can add to the regex pattern, so it matches even if theirs more code surrounding that variable.

 

^ means 'start of line' and $ means 'end of line', so if you need to match these variables anywhere in the line you have to remove these:

 

#\$SPLPF[A-Z0-9]{32}#

 

So joining it with the rest of your pattern:

 

#echo\("hey"\);[^$]*\$SPLPF[A-Z0-9]{32}#

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.