Re: regular expression for (NOT 'word')
| From: | Ando Saabas | Date: | Thu, 14 Mar 2002 15:52:34 +0000 |
| Subject: | Re: regular expression for (NOT 'word') | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-88525@lists.php.net to get a copy of this message | ||
Ok let me explain my problem further some. I need the regular expression to
purify the html page from script tags:
I used: $file = eregi_replace("(<script(.*)>.*</script>)", " ",
$file);
Now this works fine, until theres a webpage like:
<script something>script data.</script>
Some webpage data
<script something>another script data </script>
so the regexp above replaces everything between first <script > and last
</script> ie the webpage data also.
So i thought to change the regexp to something like this: $file =
eregi_replace("(<script(.*)>NOT(script)</script>)", " ", $file);
where NOT(script) would match everything that contains word script
Rick Emery wrote:
> the best you can do is:
>
> <?php
> $a = "this has php in the string";
> if( ! ereg("php", $a ) )
> { print "a: not in string"; }
> $a = "this has in the string";
> if( ! ereg("php", $a ) )
> { print "b: not in string"; }
> ?>
>
> -----Original Message-----
> From: Ando Saabas [mailto:ando.saabas@ttu.ee]
> Sent: Thursday, March 14, 2002 9:33 AM
> To: php-general@lists.php.net
> Subject: [PHP] regular expression for (NOT 'word')
>
> how would i build a regular expression in php that would match
> everything but the given word. For example, match the string only if
> there isnt a word 'php' in the string.
> I understand i can list characters i dont want to see in the string:
> [^php].
> but this means there cant be any p or h in the string. And ^(php) checks
> if the string starts with 'php'.
> How should i do it?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php