posix-ere

Why is this regular expression match positive?

Given the pattern ^[a-zA-Z0-9 .\-_]+$ and the string te\\st, why is the match positive? I'm using this to validate usernames and I don't want people to put slashes in their usernames, it messes with URLs. I'm calling ereg($pattern, $username), running PHP version 5.2.8. ...

PHP - REG_BADBR error when using ereg() for regexp

Hello, I have this piece of code for email verification : function VerifRegisterEmail(&$email) { if(empty($email)) { return false; } $pattern_email = '^[[:alnum:]\.-_]+@[[:alnum:]\.-_]+\.[[:alpha:]]{2, 3}$'; if(!ereg('^[[:alnum:]\.-_]+@[[:alnum:]\.-_]+\.[[:alpha:]]{2, 3}$', $email)) { echo "emaill"; return false; ...

PHP ereg_replace questions

A couple of PHP ereg_replace questions. I have an array of names: $ssKeywords = array("Str", "Int", "String", "As", "Integer", "Variant"); However when I use this ereg_replace: foreach($arKeyword as $aWord) { $sCode = ereg_replace($aWord, "<span class='ssKeyword'>".$aWord."</span>", $sCode); } It will only find the "str" or "int"...

How to change PHP's eregi to preg_match

I need help, below is a small VERY basic regex to somewhat validate an email, I do realize it does not work the greatest but for my needs it is ok for now. It currently uses PHP's eregi function which php.net says is now a depreciated function and I should use preg_match instead, simply replacing erei with preg_match does not work, can...

ereg_replace for PHP 5.3 + ?

I've seen a solution for not having to rework usage of the ereg function for PHP 6: http://stackoverflow.com/questions/737198/good-alternative-to-eregi-in-php It uses if(!function_exists.... Is there a function that can be used in this way for ereg_replace? ereg_replace("<!--.*-->","",$str); ereg_replace("[^a-z,A-Z]", "", $str); Th...

PHP - Replacing ereg with preg

Hi, I'm trying to remove some deprecated code from a site. Can anyone tell me the preg equivalent of ereg_replace("<b>","<strong>",$content); Thanks. ...

Converting an eregi_replace to a preg_replace

I am trying to parse some HTML snippets and want to clean them up for various reasons (XSS et al). I am currently trying to remove all of the attributes on any tag, except for the href on a anchor. I am doing this using a sequence of eregi_replace calls, but I am sure there is a smarter way of doing this using preg_replace and just a c...

How to replace ereg?

Hi all, I'm getting the following message for some php I have to use but did not write: Deprecated: Function ereg() is deprecated in /opt/lampp/htdocs/webEchange/SiteWeb_V5/inc/html2fpdf.php on line 466 This is line 466: if(ereg('^([^=]*)=["\']?([^"\']*)["\']?$',$v,$a3)) I tried simply replacing with preg_match, but it couldn't re...

preg_match two variables with metacharacters

I have two string variables which are both file paths. The code that worked used ereg which is deprecated, so I'm trying to rewrite it using preg_match: Old code that worked: $path1 = quotemeta($path); ereg("$path1(.*)$", $path2, $matches); Using preg_match which doesn't seem to work: $path1 = quotemeta($path); preg_match("/$path1(....

PHP: How to use ereg to validate input text AND string length simultaneously?

Hi, I'm using ereg in the followin way to validate a field which can contain only numbers from 0 to 9: if(eregi("^([0-9])*$", $mynumber)) return true; However the string must have between 8 and 10 characeters. Is it possible to improve the same ereg usage to check for a valid string length as well? Thanks in advance.. all ereg tutori...

ereg_replace to preg_replace ?

How can I convert ereg_replace(".*\.(.*)$","\\1",$imgfile); to preg_replace... ? ? I'm having trouble with it? ...

Find two alternatives for ereg functions

ereg and eregi functions will be deleted from Php. Please help to find alternatives for the following ereg functions: 1) To allow IP addresses only for specific ranges: $targetAddr = "60.37..*..*"; if (!ereg($targetAddr, $_SERVER['REMOTE_ADDR'])) { die; } 2) To replace series of points like ....................... $message = ere...

Help converting PHP eregi to preg_match

Hi all, I am wondering if someone could please help me convert a piece of PHP code that is now deprecated. Here is the single line I am trying to convert: if(eregi(trim ($request_url_handler[$x]),$this->sys_request_url) && $this->id_found == 0){ It is part of a function that return the configuration settings for a website. Below is ...

Yet another php ereg fix

I have a small chunk of coding I need to take from ereg to preg_match. Here is the code. function be_file_list($d, $x) { foreach (array_diff(scandir($d), array('.', '..')) as $f) { if (is_file($d . '/' . $f) && (($x) ? ereg($x.'$',$f) : 1)) { $l[] = $f; } } return $l; } This code works as expec...

eregi replace replacement

hi, since eregi replace was deprecated on version 5.3 i want to make my program compatible with new version of php http://php.net/manual/en/function.eregi-replace.php so, i'm trying to use preg_replace like this preg_replace(",",'','20,000.00'); but come with error i'm familiar with eregi_replace(',','','20,000.00'); i'm not familia...

ereg to preg conversion

I'm a complete novice when it comes to regex. Could someone help me convert the following expression to preg? ereg('[a-zA-Z0-9]+[[:punct:]]+', $password) An explanation to accompany any solution would be especially useful!!!! ...

PHP expressions fail when changing from ereg to preg_match

I have a class that uses PHP's ereg() which is deprecated. Looking on PHP.net I thought I could just get away and change to preg_match() But I get errors with the regular expressions or they fail!! Here are two examples: function input_login() { if (ereg("[^-_@\.A-Za-z0-9]", $input_value)) { // WORKS // if (preg_match("[^-_@\....

Problem with ereg deprecated

Can some please help me to rewrite these code: if (eregi($asked,$accepted)) { $this->plot_type = $which_pt; return true; } else { $this->DrawError('$which_pt not an acceptable plot type'); return false; } Any help will be highly appreciated, I have tried all the fix I got through Google but none has been able to fix it. Thanks. ...

Eregi to preg_replace change for php 5.3 compatibility help

I have this line in one of my scripts and its throwing a deprecated error. eregi_replace( '\.([a-z]{3,4})$', "-{$width}x{$height}.\\1", $src ); Can someone show me how to turn this into preg_replace and tell me why and which bits of it need to change so I can learn for future changes? I have had a go myself but where this bit of code...