Questions tagged [ereg-replace]

ereg_replace() is a PHP function that performs string replacement using regular expressions.

ereg_replace() is a PHP function that performs string replacement using regular expressions.

This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged. See https://php.net/manual/en/function.ereg-replace.php.

50 questions
1
vote
3 answers

Using ereg_replace or preg_replace to leave part of a filename in php

I am trying to leave only the prefix (WST in the example below) and the number. Any suffix and file extension should be removed. This should leave me with the product code in tact. Here are three possible values: 39159 FLAN.jpg 22201-HAV.jpg WST…
Andy
  • 2,991
  • 9
  • 43
  • 62
1
vote
1 answer

Need to replace deprecated ereg_replace

I am working for a non-profit and i'm not an expert in PHP. I need to replace the following code: $status = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "\\0", $status); When I attempt to modify it to…
1
vote
3 answers

php and regex, how to strip the dollar sign and percentage sign if a user inputs it?

Basically what this needs to do is only accept a price value, that can only be 40 or 39.95 or 100.09 or 4 etc, if the user enters anything other than a digit into the field it comes back with an error. My question: how can I change it so that if…
amanda89
  • 17
  • 1
  • 2
  • 3
1
vote
1 answer

php 5.3 ereg_replace to preg_replace

$this->Settings = array( "host" => $host , "user" => $user , "pass" => $pass ); $this->db = $db; $this->Settings["name"] = ereg_replace ("_", "", $this->db); $this->init(); I have an application that can't work after migrating to php…
Potential Coder
  • 91
  • 3
  • 11
1
vote
3 answers

PHP ereg_replace

I have this file that I am uploading to the server via php file upload.. 6;'!8.jpg I used this code to remove non alphanumeric characters.. $image1 = ereg_replace("[^A-Za-z0-9]", "", $_FILES["image"]["name"]); that works fine, but it returns my…
user979331
  • 11,039
  • 73
  • 223
  • 418
0
votes
1 answer

ereg_replace to preg_replace trouble

Hello I'm upgrading a script my website uses from php 5.4 to php 7.4 and I have some issues with it: I need to switch it from ereg_replace to preg_replace yet for some reason it won't work the desired way. here is the original ereg_replace use in…
n00b007
  • 11
  • 1
0
votes
1 answer

change ereg_replace into preg_replace

It seems to be simple, but I have problem. ereg_replace("\n","\\n",$row) into preg_replace. Anyone could give me a hand?
Jeffz
  • 2,075
  • 5
  • 36
  • 51
0
votes
2 answers

ereg_replace, preg_replace and PHP 5.3.0

Possible Duplicates: Changing ereg_replace to equivalent preg_replace Converting ereg expressions to preg Can anyone show me the equivalent of : ereg_replace("\n#[^\n]*\n", "\n", $sql) in preg_replace Thanks
Antony
  • 1
  • 1
0
votes
1 answer

Change ereg_replace to preg_replace

How would I change $output = ereg_replace("", "", $output); to preg? I tried $output = preg_replace("//", "", $output); Thanks EDIT: Sorry, messed up formatting
Matt
  • 1,599
  • 3
  • 21
  • 33
0
votes
0 answers

How to send apostrophes within text to DB2 via SQL

On Zend Server we have upgraded to PHP 7 which has broken a PHP script. A user is able to paste text from a document into a text area which then is sent to a DB2 file via SQL. Prior to PHP 7 I was using this to make sure the apostrophes were being…
0
votes
3 answers

Replace ereg_match with preg_match

Dear Sir/m'am How can i replace ther deprecated ereg_replace with preg_replace or str_replace and still have the same functionality as in the code below? return ereg_replace("^(.*)%%number%%(.*)$","\\1$i\\2",$number); ///this doesnt work return…
Koenraad
  • 3
  • 2
0
votes
1 answer

Replacing characters with smileys from echoed row

I can't figure this out and isn't my strong side of codeing ether. As of right now it'll only print the first person and timestamp, not anything more.
0
votes
1 answer

ereg_replace to preg_replace and OpenX

I have a client who is running OpenX (formerly PHPAdsNew), which is no longer being developed, and is not compatible with newer versions of PHP (as ereg and its variants are depreciated); the issue here is that I can't really tell what the ereg is…
0
votes
0 answers

How to use ereg_replace to convert image link to display image

How can i use ereg to replace URL of images with tag. My images URL have two starts embraced like this **http://myimageslink/photo.jpg** i want to convert to I use ** embrace because when don't have…
Marcus
  • 295
  • 4
  • 16
0
votes
0 answers

Replacing ereg_replace now that it is deprecated

In the following lines of code, how can I convert ereg_replace to preg_replace, now that ereg_replace is deprecated. I have a file called badwords.txt which contains a long range of phrases / words (one per line) which are likely to be spam (these…
Simeon
  • 848
  • 1
  • 11
  • 34