Jump to content

locate,edit,replace text


Kizzie33

Recommended Posts

I know you can do ereg_replace(); to find and replace a specific word but i wont to know if i can edit a segment if i dont know what the middle is. I dont know what the middle is but i know whats at the start a middle

E.g.

src="http://what.ever/goeshere"

src=" and " will never change but whats in the middle will change is there a piece of code that will locate the src" and edit whats in the middle and stop at the next " ??

 

Thankyou ! And i hope i explained it in the least confusing way, im forever over complicating things

Link to comment
Share on other sites

I need to do what i put to be honest, im building a basic proxy server

the I need to change all the herf's

So it will be herf="/help/index.php"  - for example

Now herf=" will never change an it will always end with "

And once i have the /help/index.php i wont to encrypt it with any basic encryption key which can then be decrypted later.

 

Again sorry if i over complicated it

Thankyou !!

Link to comment
Share on other sites

I'm gonna assume you mean href (because herf doesn't exist), do you mean something like this:

 

$text = <<<TEXT
<a href="/help/index.php">Something</a>
Blah Blah Blah
<a href="/help/something.php">Something</a>
TEXT;

$text = preg_replace('~href="([^"]+)~', "href=\"http://www.somesite.com$1", $text);
echo $text;

 

Output:

<a href="http://www.somesite.com/help/index.php">Something</a> 
Blah Blah Blah
<a href="http://www.somesite.com/help/something.php">Something</a>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.