Questions tagged [ereg]

Old regular expression function in PHP that is now DEPRECATED in favour of preg_match()

60 questions
143
votes
4 answers

How can I convert ereg expressions to preg in PHP?

Since POSIX regular expressions (ereg) are deprecated since PHP 5.3.0, I'd like to know an easy way to convert the old expressions to PCRE (Perl Compatible Regular Expressions) (preg). Per example, I have this regular expression: eregi('^hello…
netcoder
  • 61,842
  • 17
  • 117
  • 139
32
votes
6 answers

Function ereg_replace() is deprecated - How to clear this bug?

I have written following PHP code: $input="menu=1&type=0&"; print $input."
".ereg_replace('/&/', ':::', $input); After running above code, it gives following warning, Deprecated: Function ereg_replace() is deprecated How can I resolve this…
Pradip
  • 1,267
  • 4
  • 21
  • 35
23
votes
2 answers

Troubleshooting "Delimiter must not be alphanumeric or backslash" error when changing ereg() to preg_match()

Possible Duplicate: Converting ereg expressions to preg
gordon33
  • 806
  • 3
  • 9
  • 21
8
votes
4 answers

Expected lifespan of ereg, migrating to preg

I work on a large PHP application (>1 million lines, 10 yrs old) which makes extensive use of ereg and ereg_replace - currently 1,768 unique regular expressions in 516 classes. I'm very aware why ereg is being deprecated but clearly migrating to…
Oliver Emberton
  • 944
  • 4
  • 13
6
votes
3 answers

PHP - preg_match and "Unknown modifier" error

I had that test that worked fine : if (ereg("([0-9]{2})[-./]([0-9]{2})[-./]([0-9]{4})[ ]([0-9]{2}):([0-9]{2}):([0-9]{2})", $dateToTest, $tab) == false) and as ereg is deprecated, I have replaced that test with this one : if…
Oliver
  • 21,876
  • 32
  • 134
  • 229
5
votes
3 answers

Deprecated: Function ereg() is deprecated

Possible Duplicate: How can I convert ereg expressions to preg in PHP? My contact form is othervise working but I keep getting the following error: Deprecated: Function ereg() is deprecated in/home/..... I'm really lost here but I figure this…
no0ne
  • 2,569
  • 8
  • 25
  • 40
5
votes
2 answers

why ereg("^\d{11}$",18311111111) is false?

my code is: i get false? why?
artwl
  • 3,182
  • 4
  • 32
  • 52
4
votes
6 answers

How to check if string contains only specified character set?

I'm working on string and I wonder which way is best to check if string contains only specified character set: @ ∆ SP 0 ¡ P ¿ p £ _ ! 1 A Q a q $ Φ " 2 B R b r ¥ Γ # 3 C S c s è Λ ¤ 4 D T d t é O % 5 E U …
arekstasiewicz
  • 393
  • 1
  • 11
  • 24
4
votes
2 answers

ereg() to preg_match() how?

I have kind of simple regexes that i am using. It's so simple as: "user/" "user/[A-z0-9_-]" These all work fine with ereg, but not preg. How to convert it? Thanks
Lars Hansen
  • 95
  • 1
  • 5
2
votes
1 answer

Error updating ereg call to use preg_match instead

I'm trying to convert the following ereg() call to use preg_match() instead: if (ereg('(.*/)(.*)$',$fileref,$reg) ) { This is the preg_match() call I'm attempting to replace it with: if (preg_match('(.*/)(.*)$',$fileref,$reg) ) { When I…
AlunR
  • 445
  • 3
  • 10
2
votes
2 answers

Need some help upgrading a tiny piece of ereg_replace

I have this line of code I use for SEO purposes. The only thing is that it has an ereg_replace function in it. Now I get "ereg_replace() is deprecated" error. Apparently it's not as simple as switching it to preg_replace and my RegEx-fu is not too…
Serhiy
  • 2,347
  • 3
  • 32
  • 48
2
votes
1 answer

Fatal error: Uncaught Error: Call to undefined function ereg()

I am using php v7.3.2 on Centos 7.6. Before upgrading php the version was 5.4. In v 5.4 i had no errors. But in v 7.3.2 i got this error : Fatal error: Uncaught Error: Call to undefined function ereg() in …
SilverLight
  • 17,622
  • 58
  • 171
  • 277
2
votes
1 answer

Replacing ereg_replace()

I have some legacy code I'm trying to update to run on PHP 5.4: $row['subject'] = ereg_replace('[\]', '', $row['subject']); I know I have to replace this with preg_replace, but since I've never used ereg, I'm not sure what this actually does. Is…
Noodles
  • 858
  • 3
  • 13
  • 29
1
vote
1 answer

Php ereg validating a form

Im validating a form and its easy to validate numbers, letters a-z and so on but when i got to the point where i need to validate a field which must contain only the characters (a-z and special characters such as öçğüiş) with at least one space only…
London Boy
  • 387
  • 1
  • 3
  • 14
1
vote
2 answers

ereg to preg problems

I'm using a downloaded PHP script to speed up development of my site, but I'm having a stack of 'deprecated' messages coming up relating to ereg. I'm going to turn off warnings before going live, but am trying to make sure I clear them all first! I…
Adam
  • 49
  • 2
1
2 3 4