Multiple line search

Tool for Search and Replace across multiple files.
Linda
Posts: 4
Joined: Thu Jun 23, 2011 8:15 pm

Multiple line search

Post by Linda »

Hello,
I was wondering if anyone could help me how to search for the following lines in TextCrawler.
There's a requirement to find the following words as they appear below and replace them with other names.

Thank you,

BOARD OF COMMITEE
JONATHAN BIRD, Chair • ROSA AMBER, IT Director
REGGIE BUSH • LARRY BUSH • JANETH BUSH • MARRY BUSH
LARRY BIRD, CEO
User avatar
Fool4UAnyway

Re: Multiple line search Use newline characters

Post by Fool4UAnyway »

Yes, you can "mark" the (beginning of a) new line by the \r and/or \n escape sequence(s).

For Windows files, use \r\n, or just try the Regular Expressino Tester dialog.

Searching for

first line
second line

could be done by using the regular expression

first line\r\nsecond line
(Windows)

or

first line\rsecond line
or
first line\nsecond line

for Unix or Mac files
Linda
Posts: 4
Joined: Thu Jun 23, 2011 8:15 pm

Re: Multiple line search

Post by Linda »

I tried what you'd suggested "first line\r\nsecond line"
please take a loot at this, didn't work
BOARD OF COMMITEE\r\nJONATHAN BIRD
User avatar
Fool4UAnyway

Re: Multiple line search Regular Expression or not?

Post by Fool4UAnyway »

Did you check the Regular Expression option checkbox? This will "translate" the \r\n sequence to newline characters.

I believe it is not necessary to use (a) regular expression (mode) here. If the line contents are absolute (the same for every match), you can also click the "multiline" edit button, I believe is available next to the search text input box.
User avatar
Fool4UAnyway

Re: Multiple line search Standard Search

Post by Fool4UAnyway »

You can use the Standard Search tab for this and use the button to the left of the search text edit box to enter multiple lines.

I just checked the Regular Expression search mode in the Regular Expression Tester. This does works, using the \r\n sequence.

This may seem very trivial, but would it be useful to have a non-regular expression tester (mode) as well?

It could help to quickly check if a search text or (pattern of) multiple lines are indeed found in a (copied and pasted) piece of text or single file.

This might, for instance, reveal that one, more, or all occurrences of a certain piece of text are not exactly the same as the searched "absolute" text which is "known to be present". This would indicate that a regular expression search has to be used to find all those occurrences, perhaps only varying in white space( amount)s.
User avatar
Fool4UAnyway

Re: Edit seach text lines button

Post by Fool4UAnyway »

... Do I feel foolish or what? That button is to the right of the search text edit box.
Linda
Posts: 4
Joined: Thu Jun 23, 2011 8:15 pm

Re: Multiple line search

Post by Linda »

Thank you very much for your time.

As you suggested if I copy these multiple line in Regular Expression Tester and put \r\n in between, it works.
:D
The problem is TextCrawler is not able find these lines in the rtf files. I selected the input folder , then I indicated the file Filter *.rtf. "I get "no matching found" which is not true.
Any idea.
User avatar
Fool4UAnyway

Re: Multiple line search in .RTF files?

Post by Fool4UAnyway »

You're welcome.

Try opening such a .rtf file in Notepad or in the Regular Expression Tester using the load file button.

.rtf files, as .htm(l) files, contain all kinds of tags to describe how the text should appear, what font, color etc.

You might open an .rtf file using Wordpad and then copy the contents (Ctrl+A, Ctrl+C) and paste them into the Regular Expression Tester. Then it should be just plain text and depending on the actual contents, you may of may not find that it matches the text in the search box. If it does not, this may be because of differences in white space amounts etc.

"One word \r\n" and "One word\r\n" are not exactly the same, although they may appear to be when looking at the text. The space character at the end of the first line is hardly visible, but the computer knows it's there. To match both sentences you could use the regular expression "One word ?\r\n" or "One word *\r\n" if the number of space characters isn't limited to one.
Linda
Posts: 4
Joined: Thu Jun 23, 2011 8:15 pm

Re: Multiple line search

Post by Linda »

I have 200 to 300 .rtf files and I was hoping this would work.
Thank you so much again!
User avatar
Textman

Re: Multiple line search

Post by Textman »

The problem is that the files are RTF - these aren't plain text files but a proprietary Microsoft format, so textcrawler doesn't support them and they may give odd results if you try and modify them!
Post Reply