Author |
Message |
gregexp
The Mouse Is Extension Of Arm

Joined: Feb 21, 2006
Posts: 1497
Location: In front of a screen....HELP! lol
|
Posted:
Sat Aug 05, 2006 11:03 am |
|
Perhaps I need a rethinking of all this but you all may be able to help as well.
I want to find all variables and globalize them in order to check them within a function.
This is to see how much offsite content is being persued from the server/browser.
Problem I'm having is that when I use preg_split, It returns like this:
preg_split("/(\\$)/",'testing$testingh.bklj',-1,PREG_SPLIT_DELIM_CAPTURE );
Array ( [0] => testing [1] => $ [2] => testingh.bklj )
Now this is the testing stage and I wanted results I can be sure of and not just guess at it.
I want it to print
$testingh
no period or anyother non-word character, but right now I'm working on forcing it to display at least $testingh.bklj
Until I get that far, It wont help to stop it at the period or other non-alphanumerical character.
Any help is appreciated.
On a side note, sorry guys, been working like crazy for the last week and it wont let up for at least a month so I'll still be around just not anywhere near like I used to be. Weekends are all booked too.
I know I'm so loved here
Hopefully I'll be back on a role soon enough, Just want to put the spare time I have into this project and a few others. |
_________________ For those who stand shall NEVER fall and those who fall shall RISE once more!! |
|
 |
 |
gregexp

|
Posted:
Sat Aug 05, 2006 8:23 pm |
|
Ok got it.
I did this:
$included_files = get_included_files();
foreach ($included_files as $filename) {
echo "$filename\n<BR>";
$file_contents=file_get_contents($filename);
//break down into components to turn into an array
$break=preg_split("/(\\$)/",$file_contents,-1,PREG_SPLIT_DELIM_CAPTURE );
//Join the components to make $,varname look like $varname and turns into a string again.
$string=join(',',$break);
//set search so that it will not count these as var names
$split=array('-','=','(',')',';','[',']','/','+','"','<','>','\'');
$string=str_replace('$,','$',$string);
$string=str_replace('.',',',$string);
$string=str_replace(' ',',',$string);
$string=str_replace($split,',',$string);
$string=stripslashes($string);
//format now complete, each var name should be in the correct format with other data not being necessary so lets rejoin them but now as an array
$string=preg_split('/[,]/',$string);
//print_r ($string);
//break the array up into its components.
foreach($string as $string2){
//dont show unecesary junk
$var_test=eregi('\\$',$string2);
if($var_test ==1 AND $string2!='$'){
//global $string1;
//$string1=array($string1,$string2);
echo "$string2<br>";
Hey look I'm learning regular expressions, go me
Now to Put this in a string to verify no duplicates, then to globalize all the variables to show what they are meaning.
I started working on an offsite content block but it kinda turned into a diagnostic script tool. |
|
|
|
 |
VinDSL
Life Cycles Becoming CPU Cycles

Joined: Jul 11, 2004
Posts: 614
Location: Arizona (USA) Admin: NukeCops.com Admin: Disipal Designs Admin: Lenon.com
|
Posted:
Sat Aug 05, 2006 9:02 pm |
|
darklord wrote: | Hey look I'm learning regular expressions, go me |
Regex rocks, doesn't it?
You probably already know about this place, but for ppl that don't:
http://www.regexlib.com/default.aspx
This is getting to be one of my (ahem) regular hangouts...  |
_________________ .:: "The further in you go, the bigger it gets!" ::.
.:: Only registered users can see links on this board! Get registered or login! | Only registered users can see links on this board! Get registered or login! ::. |
|
 |
 |
gregexp

|
Posted:
Sat Aug 05, 2006 9:28 pm |
|
Yeah It does rock, but I like the old fashion search('something','in_something')
but reg ex allows for a lot more functionality, but HARDER to code.
I think I'm getting it down took me about an hour to come up with those
With time.
I decided to do even more with this, I wrote all the included files into one big file.
This should help someone to know which files are actually making up the files being loaded. All in one package should make it easier for people to find errors.
Still a LOT to be done.
I think an early retirement may be necessary  |
|
|
|
 |
|