Ajuda expressão regular
Jorge Teles
jorteles em yahoo.com
Segunda Julho 31 06:05:04 PDT 2006
Olá pessoal,
estou tentando fazer há alguns dias uma expressão
regular com os dados abaixo, e querendo obter os
seguintes dados:
- O números depois de "ifDescr.";
- As strings depois de "STRING:", excluindo a string
Shelf|on|Slot;
IF-MIB::ifDescr.837 = STRING: Ethernet Shelf 1/9/1
IF-MIB::ifDescr.838 = STRING: Gigabit Ethernet 1/9/4
IF-MIB::ifDescr.839 = STRING: Loopback on shelf 1 slot
9
IF-MIB::ifDescr.840 = STRING: Reject on shelf 1 slot 9
IF-MIB::ifDescr.841 = STRING: Black Hole on shelf 1
slot 9
IF-MIB::ifDescr.842 = STRING: Inactive on shelf 1 slot
9
IF-MIB::ifDescr.843 = STRING: Local on shelf 1 slot 9
IF-MIB::ifDescr.844 = STRING: Multi Cast on shelf 1
slot 9
IF-MIB::ifDescr.845 = STRING: Console Port 1/9/2
IF-MIB::ifDescr.846 = STRING: VRouter: main
IF-MIB::ifDescr.847 = STRING: Stinger ATM Int Slot
1/9/3
A expressão que tenho é a seguinte:
.*?\.(\d+)\s.*?\:\s(\w+\s?\w+)
Essa expressão me traz para a primeira linha:
"Ethernet Shelf", tendo eu depois que substituir Shelf
por nada, mas o problema maior é o da última linha,
pois preciso da palavra "Int" junto com a string
"Stinger ATM", ou seja preciso de "Stinger ATM Int".
Quando tento então adicionar mais comandos a minha
expressão regular, acabo pegando os números no final
da linha, por exemplo "1/9/1".
Minha pergunta é: Posso e como fazer condições dentro
da expressão regular? Alguem teria alguma referência
para pesquisar?
Jorge Teles
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Mais detalhes sobre a lista de discussão SaoPaulo-pm