Find/Replace over more than one line

Newsgator Forums
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



Find/Replace over more than one line Expand / Collapse
Author
Message
Posted 3/15/2006 12:13:32 AM
Forum Member

Forum Member

Group: Forum Members
Last Login: 3/24/2006 11:50:00 PM
Posts: 4, Visits: 1
Hello,
 
I have trouble to find/replace a string if the find-string goes over more than one line.
For example:
I have the following code:
Line 1: <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
Line 2: <meta http-equiv="content-language" content="de,en,en-us">
and I want to replace both lines with a function like <? php tags() ?>
 
Unfortunately, TopStyle does not find the lines 1 & 2 in the document if I copy and paste the first two lines into the "Text to find" box. I tried with a blank inbetween but it did not help. Is there a trick to tell the system that this is a line-break or am I missing something else?
 
Thanks and regards,
Sandra
Post #14575
Posted 3/16/2006 2:27:54 PM


Forum Deity

Forum Deity

Group: Moderators
Last Login: 12/31/2008 11:01:02 AM
Posts: 1,278, Visits: 1,552
For multi-line, you need to use TopStyle regular expression mode.

Open the Replace dialog and check "Regular expression" under Options. Then click the link that appears labeled "Need help with regular expressions?" to see documentation on TS' regex handling.

In the case of your particular example, the search string would be:
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1"><meta http-equiv="content-language" content="de,en,en-us">
Note the "" between the two lines of text. That stands for new line and is the "glue" that brings the two bits together.

Be sure to test this on a copy of your files, first.



Place your ad here!
Post #14661
Posted 3/22/2006 12:22:17 AM
Forum Member

Forum Member

Group: Forum Members
Last Login: 3/24/2006 11:50:00 PM
Posts: 4, Visits: 1
Hello Jack,
thanks for your help but unfortunately it does not work for me (version 3.12). I also tried it with \r but without success.
The expression is not found, no matter what I try
Regards,
Sandra
Post #15115
Posted 3/22/2006 9:05:38 AM


Forum Deity

Forum Deity

Group: Moderators
Last Login: 12/31/2008 11:01:02 AM
Posts: 1,278, Visits: 1,552
Can you post a copy of your file here? You may need to use the .txt file extension. The forum software is a bit picky about what filetypes it will accept.


Place your ad here!
Post #15133
Posted 3/23/2006 12:40:32 AM
Forum Member

Forum Member

Group: Forum Members
Last Login: 3/24/2006 11:50:00 PM
Posts: 4, Visits: 1
Hello Jack,
please find attached the file with my comments.
Just try to replace the first two lines with another string - it does not work for me.
Thanks a lot and regards,
Sandra


  Post Attachments 
file.txt (0 views, 519 bytes)
Post #15257
Posted 3/23/2006 9:46:39 AM


Forum Deity

Forum Deity

Group: Moderators
Last Login: 12/31/2008 11:01:02 AM
Posts: 1,278, Visits: 1,552
D'oh!

When you use regular expressions, some characters are meaningful to the parser. In this case,the - and " are causing problems. You need to escape these characters in the search string by preceding them with a backslash - \.

The properly formatted search string should look like this:
<meta http\-equiv=\"content\-type\" content=\"text/html;charset=iso\-8859\-1\"><meta http\-equiv=\"content\-language\" content\=\"de,en,en\-us\">
Sorry for the confusion!



Place your ad here!
Post #15279
Posted 3/24/2006 11:55:46 PM
Forum Member

Forum Member

Group: Forum Members
Last Login: 3/24/2006 11:50:00 PM
Posts: 4, Visits: 1
Aaaargh!!! I am a blockhead
Just the other day I worked with reg.expressions in my .htaccess file and did a lot of escaping - I just did not see the wood for the trees !!!
Surely it works now, thanks a lot, Jack!
Cheers,
Sandra
Post #15453
« Prev Topic | Next Topic »


All times are GMT -7:00, Time now is 11:00am

Powered By InstantForum.NET v4.1.4 © 2009
Execution: 0.125. 9 queries. Compression Disabled.

NewsGator.com | Support | Developers | Partners | Press | Company
© Copyright 2003-2009  NewsGator Technologies, Inc. All Rights Reserved.
Copyright Information | Privacy Policy | Terms of Service
Microsoft Gold Certified Partner