Searching text with line breaks (please see screenshot)?
Moderators: Hacker, petermad, Stefan2, white
Searching text with line breaks (please see screenshot)?
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
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
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.Italiano wrote:Or some kind of a regular expression?
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.
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.
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.
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.
(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.
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?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.
No, I mean:Italiano wrote:You mean the workaround with the "\n" argument?
http://ghisler.ch/board/viewtopic.php?p=152206#152206
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?
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?
- Samuel
- Power Member
- Posts: 1930
- Joined: 2003-08-29, 15:44 UTC
- Location: Germany, Brandenburg an der Havel
- Contact:
You may upload it here without any login.
http://www.file-upload.net/
http://www.file-upload.net/
Last edited by Samuel on 2013-09-13, 06:26 UTC, edited 1 time in total.