Searching text with line breaks (please see screenshot)?

English support forum

Moderators: white, Hacker, petermad, Stefan2

Italiano
Junior Member
Junior Member
Posts: 11
Joined: 2013-09-04, 16:49 UTC

Searching text with line breaks (please see screenshot)?

Post by *Italiano »

Great forum. Looked a bit around and can't find an answer.
I'm often searching text strings that span over two lines. For
example, I want to find the text string outlined on the left of the
picture (please see link below) but Finder can't find it, seemingly
because there is a line break in between? Is it possible to put some
kind of a symbol in the search field denoting a line break? Or some
kind of a regular expression? I should note that I never know where the line break is.
Many thanks for solving this.
Link to the screen shot: Image: http://img33.imageshack.us/img33/7254/a3o5.jpg
User avatar
milo1012
Power Member
Power Member
Posts: 1158
Joined: 2012-02-02, 19:23 UTC

Post by *milo1012 »

Italiano wrote:Or some kind of a regular expression?
Yes, that would be the way to go, but AFAIK TC only uses a subset of RegEx possibilities and searches only a single line at once.
In most RegEx libraries you can set a "singleline" mode which treats line endings like characters, where you could use sth. like:
"(?s)and.*world..." in your example, but this doesn't work in TC.
You may use $ and ^ for referencing the end or start of the line but it's of no use when you need to search across lines.

Also, you could use \n to reference a line ending in a normal search expression (without RegEx),
but it's also no good if the positions of the line endings aren't firm.

Maybe someone knows a way to do it from within TC anyhow.
User avatar
white
Power Member
Power Member
Posts: 4622
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

The search using regular expressions only searches within lines.
See:
http://ghisler.ch/board/viewtopic.php?p=160130#160130
http://ghisler.ch/board/viewtopic.php?p=154898#154898

So, it is not possible this way. It might be possible using a content plugin and searching using the plugin tab.
Italiano
Junior Member
Junior Member
Posts: 11
Joined: 2013-09-04, 16:49 UTC

Post by *Italiano »

If anybody is willing to develop a plugin that searches across two lines, has my 100 eur in the pocket - 50 in advance and 50 after it's finished.
User avatar
milo1012
Power Member
Power Member
Posts: 1158
Joined: 2012-02-02, 19:23 UTC

Post by *milo1012 »

Writing such a plugin wouldn't be a problem,
(in fact I'm currently coding a RegEx util that saves all search results)
but it won't be of much use, at least not as a content plugin for TC.

You could search with such a plugin in your selected dirs/files so that you would know in which file your (multiline-)strings are,
but that's it because the exact position is not delivered.
So when viewing the resulting file(s) with TC's lister you would again need to search to get the position,
but TC would still be limited to single lines an still can't find it.

So if you just need to know if these strings exist in your files, this should be solvable.
But getting the position(s) is not possible from within TC atm.
User avatar
white
Power Member
Power Member
Posts: 4622
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

milo1012 wrote:Writing such a plugin wouldn't be a problem..
Is there a size limit for a content plugin property value?
Italiano
Junior Member
Junior Member
Posts: 11
Joined: 2013-09-04, 16:49 UTC

Post by *Italiano »

I need to know which TXT files contain the string. Then I would be able to pinpoint myself the exact location within the file; that's easy work. Again, I just need to know which files contain the string in question.
User avatar
white
Power Member
Power Member
Posts: 4622
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

Italiano wrote:I need to know which TXT files contain the string. Then I would be able to pinpoint myself the exact location within the file; that's easy work. Again, I just need to know which files contain the string in question.
Do you know about the work around by searching part of the text, feeding results to listbox and seaching these results for the next part of the text?
User avatar
milo1012
Power Member
Power Member
Posts: 1158
Joined: 2012-02-02, 19:23 UTC

Post by *milo1012 »

white wrote:Is there a size limit for a content plugin property value?
I don't think the limit is a problem...a quick look at contentplugin.HLP just says that I can use a ft_string with "maxlen":
Maximum length, in bytes, of the detection string (currently 2k).
Italiano
Junior Member
Junior Member
Posts: 11
Joined: 2013-09-04, 16:49 UTC

Post by *Italiano »

white wrote:Do you know about the work around by searching part of the text, feeding results to listbox and seaching these results for the next part of the text?
You mean the workaround with the "\n" argument? That is not useful to me as I never know where the line break is.
User avatar
white
Power Member
Power Member
Posts: 4622
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Post by *white »

Italiano wrote:You mean the workaround with the "\n" argument?
No, I mean:
http://ghisler.ch/board/viewtopic.php?p=152206#152206
Italiano
Junior Member
Junior Member
Posts: 11
Joined: 2013-09-04, 16:49 UTC

Post by *Italiano »

I didn't know that, thanks. However, since I'm always searching through thousands of files for common English words/strings this workaround takes too much time as each step would return thousands/hundredths of hits. I'd rather have a proper solution for my problem.
User avatar
milo1012
Power Member
Power Member
Posts: 1158
Joined: 2012-02-02, 19:23 UTC

Post by *milo1012 »

Well, I got a working plug-in ready and it works fine.
It's based on PCRE and is therefore more flexible than TC's RegEx engine.
(but with a slightly different syntax)
Still, like said above, it's limited to file search and of no use in Lister.
Unfortunately there's a problem I couldn't solve but it's documented clearly in contentplugin.HLP:
I can't get the user input string in the search dialog with ContentGetValue,
so I have to get the RegExpression from some external config file
and just limiting the user input to a ft_boolean.

Now, I need to know where to put the plugin.
I don't have any spare web space ATM and since I still consider the plug-in beta
I probably shouldn't upload to totalcmd.net.
Any recommendations?
Italiano
Junior Member
Junior Member
Posts: 11
Joined: 2013-09-04, 16:49 UTC

Post by *Italiano »

Can you upload on some file sharing service like dropbox?
User avatar
Samuel
Power Member
Power Member
Posts: 1930
Joined: 2003-08-29, 15:44 UTC
Location: Germany, Brandenburg an der Havel
Contact:

Post by *Samuel »

You may upload it here without any login.
http://www.file-upload.net/
Last edited by Samuel on 2013-09-13, 06:26 UTC, edited 1 time in total.
Post Reply