Mostrando postagens com marcador Regular Expression. Mostrar todas as postagens
Mostrando postagens com marcador Regular Expression. Mostrar todas as postagens

segunda-feira, 24 de janeiro de 2011

Exemplo de Expressão Regular

public static void main(String[] args){
String entrada;
String endereco;
String padrao="href=\"[a-zA-Z.0-9/:_+\-]*.jpg";
padrao="h[a-zA-Z.0-9/:_+\-]*-h/[a-zA-Z.0-9/:_+\-]*.png";
FileInputDemo aux = new FileInputDemo();
File testFile = new File("c:/Aulas/RegEx/pagina_julho_2010a.txt");
entrada = aux.getContents(testFile);
URLConnectionReader auxUrl = new URLConnectionReader();
Pattern pattern = Pattern.compile(padrao);

Matcher matcher = pattern.matcher(entrada);

boolean found = false;
while (matcher.find()) {
endereco = matcher.group().substring(6);
try {
System.out.println(endereco);
// auxUrl.urlRead(endereco);
} catch (Exception ex) {
Logger.getLogger(RegEx.class.getName()).log(Level.SEVERE, null, ex);
}
found = true;
}
if(!found){
System.out.printf("No match found.%n");
}
}
}

terça-feira, 10 de novembro de 2009

Verificar se o conteúdo de um campo postgresql é numérico

O meu problema é verificar se o conteúdo de um campo texto (resposta) é numérico.

select pergunta, resposta
from dados.itemquest
where (resposta ~ '^[0-9.-]+$');

A expressão:

where (resposta ~ '^[0-9.-]+$');

retorna true para conteúdo numérico.

terça-feira, 29 de setembro de 2009

Postgres Regular Expression

O problema hoje foi verificar se os valores do campo resposta eram valores numérios:


select resposta
from dados.itemquest
where pergunta = 'sagi_latitude'
and (resposta ~ '[-]{0,1}[0-9]{1,2}.[0-9]*')