Find and replace word if only its line contains specific string (Regex Dreamweaver) [closed]

StackOverflow https://stackoverflow.com/questions/23183653

Pergunta

I want to use Find and Replace in dream weaver to find and replace only the words which their lines contain a specific string.

Foi útil?

Solução

user3503851, Dreamweaver has a notoriously shoddy regex flavor. Nevertheless, here is a working example, tested in CS6.

Our test text:

My Untitled Document Is Here
My Beautiful Document Is Here
My Document, the Beautiful

The goal: replace "Document" with "Blog", but only in a line that contains the word "Beautiful"

Search: ((?=.*?Beautiful)[^\r\n]*)(Document)

Replace: $1Blog

Result:

My Untitled Document Is Here
My Beautiful Blog Is Here
My Blog, the Beautiful
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top