Bonjour,
j'ai une zone de text dans laquel l'utilisateur peut saisi quelque chose comme ça:
(1 and 2) or 3 ou bien (1 and (2 and 3) or 4)....
je veux une reg exp pour vérifier pour chaque parenthèse ouverte j'ai une parenthèse fermée.
#!/usr/bin/perl $str="(1 and (2 and 3) or 4)"; $str=~/(\((?:(?>[^()]+)|(?1))*\))/; ($str eq $1)?print "$1 ok\n":print "ne corresponds pas\n"; # manque une paranthese $str="(1 and (2 and 3 or 4)"; $str=~/(\((?:(?>[^()]+)|(?1))*\))/; ($s eq $1)?print "$1 ok\n":print "ne corresponds pas\n"; __END__
#!/usr/bin/perl $str="(1 and (2 and 3) or 4)"; $str=~/(\((?:(?>[^()]+)|(?1))*\))/; ($str eq $1)?print "$1 ok\n":print "ne corresponds pas\n"; # manque une paranthese $str="(1 and (2 and 3 or 4)"; $str=~/(\((?:(?>[^()]+)|(?1))*\))/; ($str eq $1)?print "$1 ok\n":print "ne corresponds pas\n"; __END__
$str=~/(\((?:(?>[^()]+)|(?1))*\))/;
var incr = 0;
var parentheseOk = false;
for(var i =0 ; i < maChaine.length; i++){
if(maChaine[i] == '('){
incr++;
}
if(maChaine[i] == ')'){
incr--;
if (incr < 0) {
break;
}
}
}
alert(incr);
parentheseOk = (incr == 0) ;
alert(parentheseOk);
Combien cela coûte-t-il au total ? Quelles aides apportent l'état et les acteurs du marché pour alléger cette charge non choisie ? Tous les détails sur Commentçamarche.net.