Desejo corresponder a todos \n
ou \r
exceto aqueles quando a linha começa com um. @
Tenho esta expressão regular: (?!^@.*\r*\n*)(\r*\n*)
Por exemplo:
@text text text
@text text text
The line break after this text should be matched
The line break after this text also should be selected
@this line break should not be selected
Portanto, as únicas quebras de linha que devem ser selecionadas são as da 2ª, 4ª, 5ª, 6ª e 7ª. Alguma ideia?
Assim?
https://regex101.com/r/bYIpiQ/2
Nota Eu não SELECIONO o texto, EU SUBSTITUO o \ n \ r ou \ n ou \ r
const text = document.getElementById("x").innerText;
document.getElementById("x").innerText=text.replace(/(^[^@].*)(\r\n|\r|\n)/gm,"$1<BR/>")
#x { font-family: "Courier New", monospace;
white-space: pre; }
<div id="x">@line 1: text text text
line 2:
@line3: text text text
line 4: The line break after this text should be matched
line 5: The line break after this text also should be selected
line 6:
@line 7: this line break should not be selected
</div>
Este artigo é coletado da Internet.
Se houver alguma infração, entre em [email protected] Delete.
deixe-me dizer algumas palavras