Jump to content

a problem with regex


izeid

Recommended Posts

I'm trying to clean up web pages before loading them into iframe using PHP and AJAX .

I'm trying to capture Any alert(anything can be here); promt(anything can be here); and window.location Javascript codes From HTML and .js Files bye using Below Regular Expression.

 

preg_replace('#^(?<alert>)(.*?)[;$]#'," ",$webpage);

 

it works fine only if alert(anything can be here);command exist in a line only but if there were any extra codes before this code in a same line , whole the line would be replaced with blank Space either. this is what i don't want to happen. I want Exact Part Of Code in Any Where even if there is any number of alert(anything can be here);

commands is a same line , I want them to be selected separately.

would you please help me whit that .... thank you...

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.