# eregi\_replace issue!

**URL:** <https://forum.kirupa.com/t/eregi-replace-issue/28799>\
**Category:** programming\
**Created:** [August 18, 2003, 6:33pm UTC](https://forum.kirupa.com/t/eregi-replace-issue/28799 "2003-08-18T18:33:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![andr\_in](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/andr_in/32/37_2.png) [@andr\_in](https://forum.kirupa.com/u/andr_in)\
**Post date:** [August 18, 2003, 6:33pm UTC](https://forum.kirupa.com/t/eregi-replace-issue/28799/1 "2003-08-18T18:33:57Z")

</div>

I am loading text from a .txt file!

$NewsTxT = fread($fp, 10240);

I want to cut out some text from the beginning and make the cut-version $Oldtext

```php

$Oldtext = eregi_replace('&newsTxT=<div align="center">(.*)</div><br><br><p align="left">News:<br><br><b>-', '', $NewsTxT);
//This part works perfectly!

```

And then I would like to have a variable $WelcomeTxT to have the value of the text that was cut out from the previous variable!

```php
$WelcomeTxT = eregi_replace($Oldtext, '', $NewsTxT);

```

So it cuts out the rest of the text from the original text!

But for some reason it’s not working! $WelcomeTxT has the same value as $NewsTxT!

Any ideas? Or any other wasy of doing this?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 18, 2003, 7:31pm UTC](https://forum.kirupa.com/t/eregi-replace-issue/28799/2 "2003-08-18T19:31:57Z")

</div>

I’m sorry I don’t really understand what you’re trying to do… it doesn’t make sense to me…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 19, 2003, 4:39pm UTC](https://forum.kirupa.com/t/eregi-replace-issue/28799/3 "2003-08-19T16:39:10Z")

</div>

doh’! 😑

ok…

I want $Oldtext to be everything that $NewsTxT is except this line:

```php

'&newsTxT=<div align="center">(.*)</div><p align="left">News:<b>-'

```

so I used eregi\_replace to cut it out from there!

Now I want $WelcomeTxT to be the text that was cut out before from $Oldtext

(this piece: ‘&newsTxT…"\>News:\< b\>-’)

so I used eregi\_replace to cut the rest of the text ($Oldtext) out of the full original text($NewsTxT) but it’s not working!The last eregi\_replace doesn’t work!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 19, 2003, 6:50pm UTC](https://forum.kirupa.com/t/eregi-replace-issue/28799/4 "2003-08-19T18:50:25Z")

</div>

well if you know what you want that text to be, why don’t you just do this:

```php

$welcomeTxt = '&newsTxT=<div align="center">(.*)</div><p align="left">News:<b>-';

$oldTxt = ($welcomeTxt, "", $newTxt);

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 20, 2003, 5:56am UTC](https://forum.kirupa.com/t/eregi-replace-issue/28799/5 "2003-08-20T05:56:27Z")

</div>

hmh… I would do that! but you see “(.\*)” in $WelcomeText that means any number of any symbols between the 2 text…s! And the thing is that I want it to display it in a textarea in a from andI want it to be changeable! So if I change it wouldn’t have to change the php script!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 20, 2003, 6:01am UTC](https://forum.kirupa.com/t/eregi-replace-issue/28799/6 "2003-08-20T06:01:47Z")

</div>

well you would have to have the script do that anyway because of the way you had it set up originally…

```php
//doing this...
$Oldtext = eregi_replace('&newsTxT=<div align="center">(.*)</div><p align="left">News:<b>-', '', $NewsTxT);

// is the same as doing this:
$welcomeText = '&newsTxT=<div align="center">(.*)</div><p align="left">News:<b>-';
$oldText = eregi_replace($welcomeText, '', $newText);

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 20, 2003, 6:57am UTC](https://forum.kirupa.com/t/eregi-replace-issue/28799/7 "2003-08-20T06:57:28Z")

</div>

humm… I think you’re right but I just found a better way to do this with fake html tags in the txt file explode() and an array!  
Thanx anyways! 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 20, 2003, 2:27pm UTC](https://forum.kirupa.com/t/eregi-replace-issue/28799/8 "2003-08-20T14:27:03Z")

</div>

good deal 🙂
