Page 1 of 1

Novice: more basic questions

Posted: Wed Feb 08, 2012 8:51 am
by terrypin
I bought WE a couple of weeks ago but for various reasons am only now trying to use it in earnest.

Am I missing something, or is help very thin on the really basic things?

The only example I could find on how to use the program was "...how to convert all HTML tags to lower case, in all HTML files in the IIS root folder and all its subfolders." So could someone step me through exactly what I do for the following much simpler example please. Not just the RegEx but the WildEdit steps, after opening the program.

I simply want to operate on a single TXT file, not a folder. Is that the lowest level that WE will let me browse to? Why not down to a file? Must I treat it as a 'Test' file to achieve that?

Anyway, then I want to do something I cannot do with my otherwise excellent TextPad, namely delete duplicate lines in the file.

So

Line 1
Line 1
Line 1 differs
Line 2
Line 2
Line 3

should become

Line 1
Line 1 differs
Line 2
Line 3

etc.

--
Terry, East Grinstead, UK

Posted: Wed Feb 08, 2012 9:24 am
by ben_josephs
Search for: ^(.*)\r\n\1$
[X] Regular expression
[ ] "." matches end of line characters [i.e., not selected]

Replace with: $1
[ ] Literal replacement [i.e., not selected]

File filters:
Include: your_file.txt

Options
Replacement format syntax
[X] Perl
OR
[X] Extended

Posted: Wed Feb 08, 2012 10:11 am
by terrypin
Many thanks for that very quick response, Ben.

I had managed to do it just a few minutes earlier after googling to this example:
http://www.regular-expressions.info/duplicatelines.html

So I used
Find ^(.*)(\r?\n\1)+$
Replace with \1

But I couldn't at first understand why it wasn't working. I'd changed the default in Options to use POSIX Extended, as shown here:

Image

I'm floundering a bit here. (I'm not a programmer or scripter, just a veteran end user.) Do I have to manually change options in both the Syntax and the Replacement sections? I see you're saying that your RegEx work with POSIX Extended (as well as PERL), so I'll try that variation shortly.

Thanks for that pointer on specifying a target file. I'd resorted to placing it in a subfolder! Is there a solid rationale for WE implementing it in this way, rather than simply allowing the file to be selected in the Browse pane?

Finally (well, for now!) am I right that the file shown in the 'Test' pane at the bottom is not affected by whatever folder is selected?

--
Terry, East Grinstead, UK

Posted: Wed Feb 08, 2012 11:31 am
by ben_josephs
Forget the TextPad style of regular expressions when working with other tools.

You need $1 in the replacement, not \1.

The regex you found is more general than mine in two respects: it allows for Unix as well as Windows line endings, and it reduces any number of adjacent identical lines (not just two of them, as in your original request) to a single line.

I don't know why WildEdit is at it is, or the details of its operation. I don't use it.