Questions tagged [ereg]

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

59 questions
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
vote
1 answer

function ereg deprecated, how to update to preg_match?:

I'm using an old php script that runs on php 5.2 but host no longer provides php below 5.4 I'm getting an error regarding function ereg that needs to be updated to preg_match but I have no idea how this is done and a look around the web isn't too…
robert
  • 11
  • 2
1
vote
3 answers

PHP: make a string clickable

For a Mandarin learning-tool I would like to create links for each chinese "character" within a word. For example I have the chinese word "自行车" (bicycle). Then I would like to make each of the three characters "clickable". $word = '自行车'; And the…
D. Studer
  • 1,711
  • 1
  • 16
  • 35
1
vote
3 answers

ereg function in php

When I write this code : $pat='^[A-Za-z][a-zA-Z0-9_\-\.]*@[a-zA-z0-9\-]+\.[a-zA-Z0-9\-\.]+$'; $mail='javad.y1'; ereg($pat,$mail); I'm getting this error : Deprecated: Function ereg() is deprecated in C:\wamp\www\Test\test.php on line 10
Javad Yousefi
  • 2,250
  • 4
  • 35
  • 52
1
vote
1 answer

The point of PHP's recent dropping of [[:POSIX:]] regular expression flavor

Dropping of the ereg-functions and their POSIX-regular expression flavor in later PHP versions? After reading the older posting "PHP ereg vs. preg" (Sep '09) concerned of this - and reading the official PHP statement I'm inclined to ask what this is…
rubber boots
  • 14,924
  • 5
  • 33
  • 44
1
vote
2 answers

Equivalent of ereg() call

My server is running on php 5.3 now and I need to replace this call to ereg: if (ereg("/$", $pref) === FALSE) { $pref .= '/'; } I have tried this, among other things without any success: if (preg_match('~/$~', $pref) === FALSE) This results in…
Ross Fuhrman
  • 638
  • 4
  • 13
  • 26
1
vote
1 answer

php preg_match and ereg syntax difference

I found that syntax of preg_match() and the deprecated ereg() is different. For example: I thought that preg_match('/^
(.*)
$/', $content); means the same as ereg('^
(.*)
$', $content); but I was wrong. preg_match() doesn't…
igor
  • 21
  • 3
1
vote
1 answer

Updating from ereg to preg_match

I read similar titles but I couldn't make it run.. Now, I have a code like this (originally ereg): if (preg_match("[^0-9]",$qrcode_data_string)){ if (preg_match("[^0-9A-Z \$\*\%\+\-\.\/\:]",$qrcode_data_string)) { I also tried using…
Hilmi Erdem KEREN
  • 1,949
  • 20
  • 29
0
votes
1 answer

Migration from ereg to preg_match: copying a file until a pattern repeated itself X times

I was maintaining some code using ereg, and made the migration to preg_match (not forgetting the delimiter), but it broke my function. Here is my original function, which take a file, and create a cropped copy which stopped after lines only composed…
Eldros
  • 551
  • 1
  • 9
  • 28
0
votes
1 answer

punctuation ereg_replace preg_replace

I have this snippet of code from an old OsCommerce install $pattern = $this->attributes['SEO_REMOVE_ALL_SPEC_CHARS'] == 'true' ? "([^[:alnum:]])+" : "([[:punct:]])+"; I would like to modify the…
rotezecke
  • 85
  • 1
  • 11
0
votes
3 answers

PHP ereg problem

I upgraded to PHP 5.3 and i got the error: ereg has been deprecated. What can i use to replace this?? function CheckIfAlphaNumberic($text) { if (ereg('[^A-Za-z0-9]', $text)) { unset ($text); } return $text; }
M. of CA
  • 1,496
  • 2
  • 22
  • 32
0
votes
1 answer

What is the use of "ereg_replace("\n","\\n",$row[$j])" expression?

I found one PHP script for get a database backup, there use this expression to do something, that script show call to undefined function ereg_replace() this error, if i remove this line script is working fine... how to replace this function $row[$j]…
0
votes
1 answer

How can this ereg code possibly be updated to preg_match?

I have reviewed the answers to this out the wazoo. I've googled this the same. I have a variable that works really great with php 5.4 ereg but fails miserably with the latest stuff. ereg($user.$pass, preg_replace('/\s/', '', …
user13745692
0
votes
0 answers

eregi to preg_match replacement

I am converting an old PHP4-5 script to make it PHP 7 compatible. I have the following line: if ( eregi('^'.$_POST["category"],$r->id) ) $Category_List .= (' selected '); Can I simply do this? if ( preg_match('^'.$_POST["category"],$r->id) )…
marcnyc
  • 585
  • 1
  • 4
  • 17
0
votes
0 answers

whats the correct syntax for preg_match?

I'm in the middle of trying to update/upgrade my php from 5.3 to 7.3. i have a particular page where i used the following string: if( ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2})", $start_date)&& ereg…