PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > PHP equivalent to Perl's !~
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
PHP equivalent to Perl's !~

Réponse
 
LinkBack Outils de la discussion
Vieux 18/01/2008, 20h07   #1
wes.waters@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut PHP equivalent to Perl's !~

I haven't seen any documentation on this, and searching for !~ has
been fruitless. Any suggestions, or is there no equivalent?
  Réponse avec citation
Vieux 18/01/2008, 21h06   #2
Michael Fesser
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP equivalent to Perl's !~

..oO(wes.waters@gmail.com)

>I haven't seen any documentation on this, and searching for !~ has
>been fruitless. Any suggestions, or is there no equivalent?


What about !preg_match()?

Just a guess, since I don't use Perl.

Micha
  Réponse avec citation
Vieux 19/01/2008, 10h50   #3
Toby A Inkster
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP equivalent to Perl's !~

Michael Fesser wrote:
> .oO(wes.waters@gmail.com)
>
>>I haven't seen any documentation on this, and searching for !~ has been
>>fruitless. Any suggestions, or is there no equivalent?

>
> What about !preg_match()?
> Just a guess, since I don't use Perl.


Yep, that's correct.

Perl:

if ($foo !~ /bar/)
{
print "match\n";
}

PHP:

if (!preg_match('/bar/', $foo))
{
print "match\n";
}


--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 19 days, 22:02.]

Ham vs Bacon vs Pork
http://tobyinkster.co.uk/blog/2008/01/17/pork-etc/
  Réponse avec citation
Vieux 19/01/2008, 16h08   #4
The Natural Philosopher
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP equivalent to Perl's !~

Toby A Inkster wrote:
> Michael Fesser wrote:
>> .oO(wes.waters@gmail.com)
>>
>>> I haven't seen any documentation on this, and searching for !~ has been
>>> fruitless. Any suggestions, or is there no equivalent?

>> What about !preg_match()?
>> Just a guess, since I don't use Perl.

>
> Yep, that's correct.
>
> Perl:
>
> if ($foo !~ /bar/)
> {
> print "match\n";
> }
>
> PHP:
>
> if (!preg_match('/bar/', $foo))
> {
> print "match\n";
> }
>
>

And apart from reminding me of 'pregnancy' how much more readable the
PHP is!
  Réponse avec citation
Vieux 19/01/2008, 23h44   #5
Toby A Inkster
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: PHP equivalent to Perl's !~

The Natural Philosopher wrote:

> And apart from reminding me of 'pregnancy' how much more readable the
> PHP is!


Frankly I find the Perl version far more elegant. The lack of redundant
quote marks and nested brackets if far more pleasing to the eye IMHO.

Indeed, in Perl you could use:

print "match\n" if $foo !~ /bar/;

or even:

print "match\n" unless $foo =~ /bar/;

Either seem pretty readable to me.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 20 days, 10:51.]

Ham vs Bacon vs Pork
http://tobyinkster.co.uk/blog/2008/01/17/pork-etc/
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 17h11.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11794 seconds with 13 queries