Como apagar todo o texto, exceto o que está dentro das aspas?

2

Desejo remover todo o texto, exceto o que está entre aspas.

Como eu faria isso?

Exemplo:

Bran could hear the wind in the trees, the clatter of their hooves on the ironwood planks, the whimpering of his hungry pup, but Jon was listening to something else. “There,” Jon said. He swung his horse around and galloped back across the bridge. They watched him dismount where the direwolf lay dead in the snow, watched him kneel. A moment later he was riding back to them, smiling. “He must have crawled away from the others,” Jon said. “Or been driven away,” their father said, looking at the sixth pup. His fur was white, where the rest of the litter was grey. His eyes were as red as the blood of the ragged man who had died that morning. Bran thought it curious that this pup alone would have opened his eyes while the others were still blind. “An albino,” Theon Greyjoy said with wry amusement. “This one will die even faster than the others.” Jon Snow gave his father’s ward a long, chilling look. “I think not, Greyjoy,” he said. “This one belongs to me.”

Resultado necessário:

“There,” “He must have crawled away from the others,” “Or been driven away,” “An albino,” “This one will die even faster than the others.” “I think not, Greyjoy,” “This one belongs to me.”

Ou

There, He must have crawled away from the others, Or been driven away, An albino, This one will die even faster than the others. I think not, Greyjoy, This one belongs to me.

    
por Chibi 01.10.2018 / 00:21

2 respostas

0

No editor CudaText , você pode fazer isso com várias seleções.

  • caixa de diálogo Localizar, insira ".+?" , marque a opção reg-ex
  • pressione "Selecionar tudo" na caixa de diálogo
  • o texto entre aspas é selecionado, Copiar para a área de transferência
  • criar nova guia de arquivo, Colar da área de transferência

Para unir linhas resultantes a uma, use o comando CudaExt do plugin "Join selected lines".

    
por 01.10.2018 / 08:02
0
  • Ctrl + H
  • Encontre o que: (?:^|\G)[^“”]*(“[^”]*”)
  • Substitua por: $1 ( Nota: há um espaço antes de $1 )
  • check Embrulhe
  • verificar expressão regular
  • Substituir todos

Explicação:

(?:^|\G)    : non capture group, beginning of line or posiiton of last match
[^“”]*      : 0 or more any character that is not “ or ”
(           : start group 1
    “       : opening “
    [^“”]*  : 0 or more any character that is not “ or ”
    ”       : closing ”
)           : end group

Você pode usar “([^”]*)” em vez de (“[^”]*”) se não quiser as aspas no resultado.

Substituição:

 $1         : a space followed by content of group 1

Resultado para o exemplo dado:

“There,” “He must have crawled away from the others,” “Or been driven away,” “An albino,” “This one will die even faster than the others.” “I think not, Greyjoy,” “This one belongs to me.”

    
por 01.10.2018 / 11:09