If (/start/ .. /end/) Flip Flop Mechanism

2002-03-02 Thread Steven M. Klass
Hi all I know there is a flip flop option but I'm not sure thats what I need.. Here is what I want to do - and I have no idea how to do this. Basically I have a section of text that I am doing a search and replace operation. The problem is what if the search text doesn't exist - I st

Re: If (/start/ .. /end/) Flip Flop Mechanism

2002-03-02 Thread Tor Hildrum
On 2/3/02 12:06, "Steven M. Klass" <[EMAIL PROTECTED]> wrote: > Hi all > > I know there is a flip flop option but I'm not sure thats what I need.. > Here is what I want to do - and I have no idea how to do this. > > Basically I have a section of text that I am doing a search and replace > opera

Re: If (/start/ .. /end/) Flip Flop Mechanism

2002-03-03 Thread Todd A. Jacobs
On Sat, 2 Mar 2002, Steven M. Klass wrote: > if (/start/ .. /end/){ >s/^foo/bar/; > > } Just add an alternative match: if (/start/ .. /end/) { s/^foo/bar/ or s/^/bar/ ; } -- "The only thing that helps me maintain my slender grip on reality is the friendshi

Re: If (/start/ .. /end/) Flip Flop Mechanism

2002-03-03 Thread Jeff 'japhy' Pinyan
On Mar 3, Todd A. Jacobs said: >On Sat, 2 Mar 2002, Steven M. Klass wrote: > >> if (/start/ .. /end/){ >>s/^foo/bar/; >> >> } > > s/^foo/bar/ or s/^/bar/ ; You can just say: s/^(foo)?/bar/; or, if you like, s/^(?:foo)?/bar/; or even omit the ^. -- Jeff "japhy" Pinyan

Re: If (/start/ .. /end/) Flip Flop Mechanism

2002-03-04 Thread Steven M. Klass
Hi again, But how does this allow me to say "Search for foo and replace it with bar. if you get to the end without finding foo add this line (which incidentally is the full line including foo and bar) Example File contains foo1 = bar1 foo2 = bar2 foo4 = bar4 search for foo1 and repla