Eu já vi esse tipo de erro acontecer inúmeras vezes (aliás, enquanto escrevia este email enxerguei outro problema, vou mencioná-lo depois) :<br><br>1. A pessoa quer pegar algo entre aspas, e usa a regexp: /"(.*?)"/
<br><br>2. Daí a pessoa quer dizer que dentro das aspas não pode ter a palavra "all"<br><br>3. Então, a pessoa escreve: <span style="font-family: courier new,monospace;">/"([^(all)]*?)"/</span><br><br>
4. E como isso de fato não bate com "all", a pessoa fica feliz.<br><br>Eis o erro: <span style="font-family: courier new,monospace;">[aeiou]</span> bate com qualquer caractere dentre <span style="font-weight: bold;">
a</span>, <span style="font-weight: bold;">e</span>,<span style="font-weight: bold;"> i</span>, <span style="font-weight: bold;">o</span>, ou <span style="font-weight: bold;">u</span>.<br><span style="font-family: courier new,monospace;">
[^aeiou]</span> bate com qualquer caractere, exceto <span style="font-weight: bold;">a</span>, <span style="font-weight: bold;">e</span>, <span style="font-weight: bold;">i</span>, <span style="font-weight: bold;">o</span>
, e <span style="font-weight: bold;">u</span>.<br><br><span style="font-family: courier new,monospace;">[^(all)]</span> é igual a <span style="font-family: courier new,monospace;">[^()al]</span> : qualquer caractere, exceto
<span style="font-weight: bold;">(</span>, <span style="font-weight: bold;">)</span>, <span style="font-weight: bold;">a</span>, ou <span style="font-weight: bold;">l</span><br><br>Para negar a presença de uma seqüência inteira, pode-se usar um "negative lookahead":
<br><br><span style="font-family: courier new,monospace;">/"<span style="font-weight: bold;">(?!all")</span>(.*?)"/</span><br><br>Onde <span style="font-family: courier new,monospace;">(?!all)</span> indica que, a partir daquele ponto não pode bater com
<span style="font-family: courier new,monospace;">all".<br></span><br>Ah sim, e agora o outro problema que me lembrei acima:<br><br>Gabriel escreveu <span style="font-family: courier new,monospace;">"(.+?)".
</span><br><br>No exemplo abaixo:<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"><option value=""></option></span><span style="font-family: courier new,monospace;">
<option value="foo"></option></span><br><br>a regexp vai capturar em $1: <span style="font-family: courier new,monospace;">"></option><option value=</span>. <br><br><span style="font-family: courier new,monospace;">
<option value="<span style="font-weight: bold; text-decoration: underline;">"></option></span></span><span style="font-family: courier new,monospace;"><span style="font-weight: bold; text-decoration: underline;">
<option value=</span>"foo"></option></span><br><br><div><span class="gmail_quote"><br><br>On 2/1/07, <b class="gmail_sendername">Gabriel Vieira</b> <<a href="mailto:gabriel.vieira@gmail.com">gabriel.vieira@gmail.com
</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">$teste = "<option value=\"all\">oi</option><option value=\"\">ola</option><option value=\":D\">opa</option>";
<br>print "$1\n" while $teste =~ /value="([^(all)]+?)"/ig;
<br><br>aqui funcionou :P<div><span class="q" id="q_1107ed2eedb90e51_1"><br></span></div></blockquote></div><br clear="all"><br>-- <br>[]s<br>Wendel<br><br>"Não ajustar o auto-ajuste" - <a href="http://wendel.scardua.net/">
http://wendel.scardua.net/</a>