www_puertoricoautoforo_com
asked on
Notepad++ REGEX (delete * between DIV tags, multiple lines)
Here's what I have..
<script type="text/javascript">
sflkjasdfkjsafsf sdf sdf sdf sdf sd f
sjd ssdf fsf sdf sdf sdf sdslfjsklfjsdlkfjs
dfsf sf sfd sf sdf
dflksdfjklsdf sdd s
sdkfsdklsd sdf sdfs df f sjfsdklfsdf
</script>
I'm trying to delete everything between the scripts.. So all I'm left with is this..
<script type="text/javascript"></s cript>
Is there someway to delete * between <script type="text/javascript"> and </script>?
<script type="text/javascript">
sflkjasdfkjsafsf sdf sdf sdf sdf sd f
sjd ssdf fsf sdf sdf sdf sdslfjsklfjsdlkfjs
dfsf sf sfd sf sdf
dflksdfjklsdf sdd s
sdkfsdklsd sdf sdfs df f sjfsdklfsdf
</script>
I'm trying to delete everything between the scripts.. So all I'm left with is this..
<script type="text/javascript"></s
Is there someway to delete * between <script type="text/javascript"> and </script>?
I had a go at this using notepad++, and it's not trivial. It's not great at matching multiple lines.
Do you need to do this just once, or on an ongoing basis? You might be best using a different tool, depending on your answer
Do you need to do this just once, or on an ongoing basis? You might be best using a different tool, depending on your answer
ASKER
well I need it every now and then... if there is a php-based regex solution I can use that too. I have a directory of files that I need to run it on.
PHP is ideal. If you can read the file into a variable, it should be as simple as this:
$html = (the contents of your file)
$pattern="@(<script type=\"text/javascript\">) .*?(</scri pt>)@s";
$replacement="$1$2";
$fixed_html = preg_replace($pattern, $replacement, $html);
$html = (the contents of your file)
$pattern="@(<script type=\"text/javascript\">)
$replacement="$1$2";
$fixed_html = preg_replace($pattern, $replacement, $html);
ASKER
Awesome, but how would I go about saving the file after that change and opening all the files in a directory?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for all the help, can you shoot me a sample script that preforms the whole tamale?
I'll try it on my windows machine and if it doesn't work I'll use my linux server just in case.
I'll try it on my windows machine and if it doesn't work I'll use my linux server just in case.
Sorry, I don't have time today to put that all together. I'm happy to help with any issues if you give it a go though.
ASKER
NOTEPAD++
it has a find and replace regex feature.