Boyd, Todd M. tmbo...@ccis.edu wrote in message
news:33bde0b2c17eef46acbe00537cf2a190037b7...@exchcluster.ccis.edu...
Mike -- I've bottom posted my reply, as is the convention for this list
(and most others). Scroll down.
From: Mike Peloso [mailto:mpel...@princeton.edu]
Sent: Thursday, December 18, 2008 9:56 AM
To: Boyd, Todd M.
Subject: Php question from Newsgroup
Todd,
I have attached a few jpgs to show the problems I am having (With both of my
recent posts)
Any questions you can call me.
The first one shows the value of the php file I am trying to parse.( I cant
set any of those directives,) I can't set php.ini per dir
The second shows what your REGEX looks like as its being sent to:
preg_match_all($regex, $test2, $result, PREG_PATTERN_ORDER);
As you can see there is a whole lot of escaping going on here.
Thanks
Mike
Heres all the code:
?php
process_uploaded_file('letter');
function process_uploaded_file($fname) {
// Assumes set of $_POST variables in the form: name, name_fname, name_size,
name_type
$_POST[$fname.'_fname'] = $_FILES[$fname]['name'];
$_POST[$fname.'_size'] = $_FILES[$fname]['size'];
$_POST[$fname.'_type'] = $_FILES[$fname]['type'];
$_POST[$fname.'_fname'] = strtr($_POST[$fname.'_fname'],'
%*;:{}[]|\,/()%...@!',''); //fix special chars in
name
$_POST[$fname.'_fname'] = strtr($_POST[$fname.'_fname'],',_);
$fileHandle = fopen($_FILES[$fname]['tmp_name'], r);
$_POST[$fname] =stripslashes(fread($fileHandle, $_POST[$fname.'_size']));
$test=$_POST[$fname];
$test3=stripslashes($test);
//$regex='/function [a-z]* *([$a-zA-Z]*)/';
//$regex='/function [a-z]* *(?$[a-z]*)?/';
$regex = '/function\s+[-_a-z0-9]+\s*\((\s*$\?[-_a-z0-9]+\s*,?)*\s*\)/i';
$functions=do_reg($regex,$test);
}
function do_reg($regex,$test)
{ $test2=preg_quote($test);
preg_match_all($regex, $test2, $result, PREG_PATTERN_ORDER);
return $result = $result[0];
}
?
Mike,
You are using preg_quote(). This will add slashes to every special RegEx
character in your pattern (i.e., parentheses and dollar signs, etc.). Try
performing your RegEx search without using preg_quote() and let me know if
it does any better. Also--try to keep your replies on the PHP List, as the
information in them can be used by others on their own projects.
// Todd
Were getting there
The only fuction i get is one without any parameters.
I'll play with it, but if you see an error in your regex let me know.
Thanks
Mike
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php