Ask a Question related to PHP Development, Design and Development.
-
Joseph Luner #1
Regular expression newbie question
How do I write "not" in regular expression? I am new to reg exp. I want to
check the string which does not contain "http://"
I wrote /\bhttp:\/\/\b/
It returns True if the string contains "http://" , however what I want is to
make it return False when it contains "http://". How do I write it?
Thanks...
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
Version: 6.0.576 / Virus Database: 365 - Release Date: 1/30/2004
Joseph Luner Guest
-
Very simple regular expression question (ASP/VBScript)
I need a regular expression pattern that will match repeating "leafs" of XML individually, e.g. <link LinkName="Link1"... -
cfform regular expression question
Hey, Quick question for you. I am trying to use cfform to validate for an email address. How do I do? <cfinput type="text" name="cstreet2" ... -
Regular Expression Question
Hello, is it possible to make a regular expression match for the following situation: I have a string, looking like 'foobarbarbar'. I don't... -
Regular Expression - BackReferences Question
I have a file containing the following URL in it http://www.somesite.com/folder/1.gif Now, everyday I need to run a script so that 1.gif in the... -
[PHP] Regular expression question
well, first off '>' should not be allowed as a value of an attr="" pair anyways. You should convert it to > or < this will solve that problem.... -
Cameron #2
Re: Regular expression newbie question
Joseph Luner wrote:
Don't use a regular expression for that, it's not needed strpos would be> How do I write "not" in regular expression? I am new to reg exp. I want to
> check the string which does not contain "http://"
>
> I wrote /\bhttp:\/\/\b/
>
> It returns True if the string contains "http://" , however what I want is to
> make it return False when it contains "http://". How do I write it?
> Thanks...
>
>
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
> Version: 6.0.576 / Virus Database: 365 - Release Date: 1/30/2004
>
>
faster.
if (!strpos("http://www.php.net", "http://") === FALSE)
echo "http:// not found in string";
else
echo "http:// found in string";
this will obviously echo http:// found in string
Cameron Guest
-
Cameron #3
Re: Regular expression newbie question
Cameron wrote:
> Joseph Luner wrote:
>>>> How do I write "not" in regular expression? I am new to reg exp. I
>> want to
>> check the string which does not contain "http://"
>>
>> I wrote /\bhttp:\/\/\b/
>>
>> It returns True if the string contains "http://" , however what I want
>> is to
>> make it return False when it contains "http://". How do I write it?
>> Thanks...
>>
>>
>>
>>
>> ---
>> Outgoing mail is certified Virus Free.
>> Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
>> Version: 6.0.576 / Virus Database: 365 - Release Date: 1/30/2004
>>
>>
> Don't use a regular expression for that, it's not needed strpos would be
> faster.
>
>
> if (!strpos("http://www.php.net", "http://") === FALSE)
> echo "http:// not found in string";
> else
> echo "http:// found in string";
>
>
> this will obviously echo http:// found in string
Err sorry, ignore the ! bfore strpos
~Cameron
Cameron Guest
-
Joseph Luner #4
Re: Regular expression newbie question
I know I can do it with strpos, but I need to use regular expression. Would
you tell me how?
To be exact, I am using a library called Vdaemon (a .NET like form
validation library via XML for PHP, it's very very cool)
[url]http://www.x-code.com/vdaemon_web_form_validation.php[/url]
"Cameron" <foo@bar.invalid> wrote in message
news:bvkikl$7ch$1@news5.svr.pol.co.uk...want to> Joseph Luner wrote:> > How do I write "not" in regular expression? I am new to reg exp. Iis to> > check the string which does not contain "http://"
> >
> > I wrote /\bhttp:\/\/\b/
> >
> > It returns True if the string contains "http://" , however what I want>> > make it return False when it contains "http://". How do I write it?
> > Thanks...
> >
> >
> >
> >
> > ---
> > Outgoing mail is certified Virus Free.
> > Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
> > Version: 6.0.576 / Virus Database: 365 - Release Date: 1/30/2004
> >
> >
> Don't use a regular expression for that, it's not needed strpos would be
> faster.
>
>
> if (!strpos("http://www.php.net", "http://") === FALSE)
> echo "http:// not found in string";
> else
> echo "http:// found in string";
>
>
> this will obviously echo http:// found in string
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
Version: 6.0.576 / Virus Database: 365 - Release Date: 1/30/2004
Joseph Luner Guest
-
Duyet The Vo #5
Re: Regular expression newbie question
PHPEdit has a nice RegExpEditor tool
[url]http://www.phpedit.net/products/RegExpEditor/[/url]
"Joseph Luner" <J0s4phLun3r_N0SPAMMM@yahoo.com> wrote in message
news:RgjTb.94314$9Ce1.89193@news04.bloor.is.net.ca ble.rogers.com...to> How do I write "not" in regular expression? I am new to reg exp. I wantto> check the string which does not contain "http://"
>
> I wrote /\bhttp:\/\/\b/
>
> It returns True if the string contains "http://" , however what I want is> make it return False when it contains "http://". How do I write it?
> Thanks...
>
>
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
> Version: 6.0.576 / Virus Database: 365 - Release Date: 1/30/2004
>
>
Duyet The Vo Guest
-
Beable van Polasm #6
Re: Regular expression newbie question
"Joseph Luner" <J0s4phLun3r_N0SPAMMM@yahoo.com> writes:
> How do I write "not" in regular expression? I am new to reg exp. I want to
> check the string which does not contain "http://"
>
> I wrote /\bhttp:\/\/\b/
>
> It returns True if the string contains "http://" , however what I want is to
> make it return False when it contains "http://". How do I write it?
> Thanks...
<?php
error_reporting(E_ALL);
$str1 = "http://google.com";
$str2 = "google.com";
if (preg_match("/\bhttp:\/\/\b/", $str1))
{
echo "str1 matches http\n";
}
else
{
echo "str1 doesn't match http\n";
}
if (preg_match("/\bhttp:\/\/\b/", $str2))
{
echo "str2 matches http\n";
}
else
{
echo "str2 doesn't match http\n";
}
if (! preg_match("/\bhttp:\/\/\b/", $str1))
{
echo "str1 doesn't match http\n";
}
else
{
echo "str1 matches http\n";
}
if (! preg_match("/\bhttp:\/\/\b/", $str2))
{
echo "str2 doesn't match http\n";
}
else
{
echo "str2 matches http\n";
}
?>
--
The guy's a troll. Ignore him. -- Captain Jean-Luc Picard
The guy's not even the real Jean-Luc Picard. Ignore him. -- Etienne Rouette
[url]http://beable.com/[/url]
Beable van Polasm Guest



Reply With Quote

