Page 1 of 1
copy all lines with search phrase
Posted: Wed Oct 20, 2010 5:31 am
by josh12345
I'm sorting a text file of and I'm trying to figure out if there's a way to copy all lines that the word I'm searching for occurs in.
If not, I'm assuming there is at least a workaround for this with a regex of some sort. It's a list of url's, so every line starts with "http://". Beyond that, I'm wondering if there is a regex that would take care of any word I'm looking for and find the whole line.
This isn't my attempt at creating a regex string, but it seems it would go something like:
"http:// regex for matching any text here [the word I'm searching for] regex for all text at the end of the line"
The word I'm searching for will always be somewhere in the middle of the url.
Thanks
Posted: Wed Oct 20, 2010 8:59 pm
by Fool4UAnyway
How about this one?
Find:
http://.*word.*
You can then use the Extract button to get the list of occurrences (line parts, starting from http:)
By the way, in Notepad++ you can use the same regular expression, check the Mark Line option and press the Find All button. You can then copy the _complete_ lines to the clipboard by using the Copy Bookmarked Lines option in the Search menu.
Did you succeed in unsorting the other file?
Posted: Thu Oct 21, 2010 2:29 am
by josh12345
Hey thanks Fool4UAnyway,
For some reason that one wasn't working for me when I tried it in text crawler before. Maybe I typed something in wrong.
I know it's not rocket science but I was having quite a tough time with the other regex in notepad++. All because I put an extra blank space (pressing spacebar) at the end of it. (which I had no idea would effect it at first)
I actually ended up figuring this one out! (I know, easy stuff for an expert, but a nice regex baby step for me.)
I needed each occurence to be on it's own line, so I tried this and it worked:
http://.+any word or phrase here.+\r\n
It does put an extra blank line in that I don't want, but I at least have an easy way to get rid of those if there isn't any other any to put each occurence on it's own line.
Thanks for the help on all the easy stuff!
Posted: Thu Oct 21, 2010 2:31 am
by josh12345
I meant "any other WAY" second to last line. Typo.
Posted: Thu Oct 21, 2010 2:38 am
by josh12345
The reason I was using text crawler over notepad++ for this was text crawler seems to be able to handle larger file sizes than notepad++.
Notepad++ was crashing on me.
Posted: Thu Oct 21, 2010 9:34 pm
by Fool4UAnyway
Oh, sure, I still have been using Text Crawler 1.1.4 up till now... and I intend to keep using it, here's why.
I just installed TextCrawler 2 and noticed what you describe.
If I do not put \r\n behind the regex, all http:// matches in the Scratchpad are put on one and the same line behind each other. This may be a correct interpretation of "what to do".
However, if I put \r\n there, all http:// matches in the Scratchpad are separated by a blank line.
It seems that \r\n results in two new line characters being added between the matches. This is not what I would expect and is not in line with "what to do" in that it is not consistent with the previous situation.
Is this a bug?
In Text Crawler 1.1.4 there is no need to add the \r\n, because the Extract button will show all matches on individual lines. Adding \r\n to the expression will also add just a single blank line between each http:// line. This is consistent behavior.
I also like the possibility to use ^ and $ for the start and end of lines, respectively, in Text Crawler 1.1.4. It seems to better match with the way I work and I expect it to work.
Posted: Fri Oct 22, 2010 9:38 pm
by Fool4UAnyway
By the way, if you hadn't already found out yourself, you can easily get rid off all but one of the extra blank lines by using the Remove Duplicate Lines option in the Scratchpad. You just have to remove the single blank line that is left manually.
Posted: Mon Oct 25, 2010 1:53 pm
by DV
This is odd behaviour - I'll put it in the TextCrawler 2.1 to-do list!