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

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

Вопрос

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

Это было полезно?

Решение

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
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top