Page 1 of 1

Search for top of file?

Posted: Wed Feb 03, 2010 5:54 pm
by Mike Olds
Hello,

I am having a strange problem with WE.

I am looking to replace:

<html>
<head>

Which begins the files to be corrected, and to replace with:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="stylesheet" type="text/css" href="../../admin/styles/common.css" />
<title></title>
</head>

<body>

<div class="ctr">
<center>
<table cellspacing="0" cellpadding="6" width="80%">
<tr>
<td>

I am able to do this in a test file, but when it comes to the actual files I get no files matching.

I suspect some sort of quirk with regard to coding or some such, but I would only really like a solution. Is there a way for me to insert this doctype information at the start of the first line on a file, without reference to anything but the beginning of the first line to search for?

Search: ^ ?

Re: Search for top of file?

Posted: Wed Feb 03, 2010 11:04 pm
by ben_josephs
Your problem may be due to differences in the line endings (not the encoding). Have you experimented with the setting of
Options | Literal line break characters?
Mike Olds wrote:Is there a way for me to insert this doctype information at the start of the first line on a file
Try searching for
\A
(with Regular expression selected), which is supposed to match the beginning of the file only. Experiment with this: there are bugs in its implementation, and it doesn't always behave as expected.

Posted: Thu Feb 04, 2010 11:07 am
by Mike Olds
Hello Ben,

Thanks for the hint. It was 'linefeed only' the unix option. Bing! All done.

end ?

Posted: Thu Feb 04, 2010 11:43 am
by Mike Olds
OK, so now how do I find the end of the file?

I tried *^^

and fiddled again with the line endings, but no go.

Posted: Thu Feb 04, 2010 12:58 pm
by ben_josephs
\z matches at the end of the file.
\Z is supposed to match an optional sequence of newlines (not carriage returns) at the end of the file, but it doesn't work correctly.

Posted: Thu Feb 04, 2010 3:37 pm
by helios
The implementation of "\Z" is buggy, so "\n*\z" should be used instead.

Posted: Thu Feb 04, 2010 3:46 pm
by Mike Olds
Thanks all.