bon j'ai trouvé le problème :
c'est \s* qui ne marche pas
du coup j'ai fait caractères par caratères ce qui me donne :
var ereg_faits = /\<tr\>\<td\>\<a href\="javascript\:;" onclick\="return profil\(event,'.+'\);"\>(.+)\<\/a\>\<\/td\>[\r\n]{1,2}\t\t\t\<td nowrap\>([0-9]+) dollars\<\/td\>[\r\n]{1,2}\t\t\t\<td\>\<a href\='\/jeu\/defi\.php\?id_defi\=([0-9]+)&id_adv\=([0-9]+)'\>Voir le défi\<\/a\>\<\/td\>[\r\n]{1,2}\t\t\t\<\/tr\>/g;
pour ça j'ai un script php qui m'échappe tout seul les caractères avec preg_quote
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| <?php
if(isset($_POST['txt'])){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<fieldset>
<legend>PREG-QUOTE</legend>
<pre><?php
$src = array("/\\t/","/\\n/","/\\r/");
$dst = array("\\t" ,"\\n" ,"\\r");
echo preg_replace($src, $dst, htmlspecialchars(preg_quote(stripslashes($_POST['txt']),"/")));
?></pre>
</fieldset>
</body>
</html>
<?php } else { ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script>
var num = 3;
function ajouter(){
document.getElementById('leLigneDeRemplacement').innerHTML += '<tr><td><input name="src'+num+'" type="text" /></td><td><input name="dst'+num+'" type="text" /></td></tr>';
num++;
}
</script>
<style type="text/css">
textarea {
width: 800px;
height: 350px;
}
thead > tr > td {
text-align: center;
}
</style>
</head>
<body>
<form action="testEreg.php" method="post">
<textarea name="txt"></textarea>
<br />
<input type="submit" />
</form>
</body>
</html>
<?php
}
?> |
PS: d'ailleur le preg_replace est un peu violent :/
Partager