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  :-\

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

^ 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}#

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.