| Code Perl |
sub attrText {local($cas,$nom,$TIN) = @_;
if (!(defined $$TIN{$nom})) {return ''}
local $x = $$TIN{$nom};
if ($cas ne "") {
if ($x!~/(\/#$cas=)/) {return ''}
$x = substr($x,index($x,$1)+length($1));
}
if (index($x,"/#")!=-1) {$x = substr($x,0,index($x,"/#"))}
$x =~ s/^\s*//; $x =~ s/\s*$//;
return $x;
}
|
| Code JavaScript |
function attrText(cas,nom,TIN) {
if (typeof(TIN[0][nom])=="undefined") {return ''}
var x = TIN[0][nom];
if (cas!="") {
if (!x.match(new RegExp("(\\\/#"+cas+"=)"))) {return ''}
x = x.substr(x.indexOf(RegExp.$1)+RegExp.$1.length);
}
if (x.indexOf("/#")!=-1) {x = x.substr(0,x.indexOf("/#"))}
x = x.replace(/^\s*/,""); x = x.replace(/\s*$/,"");
return x;
}
|