about selection
-
@PeterJones said in about selection:
edit: sorry, @astrosofista , for hijacking your thread with this tangent.
Nothing to be sorry about, and for sure the info is quite relevant, so I am paying attention.
-
I get your points and I think they are quite reasonable. However and unfortunately I don’t clearly see the reddish text inside backtickets displayed on a black background —my better option—, so I feel the need to look for other color(s) to easy my reading.
Now, concerning your ideal way of extracting data from the Find window, I like the idea and depending on how much use I could give it, I will probably develop my own, thank you for the inspiration! :-)
Best Regards
-
@astrosofista said in about selection:
reverse all the lines between hashes and only those
@cisco779k said:
@ astrosofista
you understand what I want to do@cisco779k
I’m aware this problem has largely been solved but thought it an interesting enough exercise to see if another method could be obtained by keeping the file intact and not having to use a plugin or export lines to another file. I think I’ve come up with a solution. It’s not original, indeed I knew of anoher solution employing this technique provided by @guy038 some time ago to pad out numbers (right justify).So my regex is
Find What:(?-s)(^[^#]{3}.+\R)?(^[^#]{3}.+\R)?(^[^#]{3}.+\R)?(^[^#]{3}.+\R)?(^[^#]{3}.+\R)?(^[^#]{3}.+\R)?(^[^#]{3}.+\R)?(^[^#]{3}.+\R)?(^[^#]{3}.+\R)
Replace With:\9\8\7\6\5\4\3\2\1
So at the moment it cannot work with more than 9 lines grouped together, however the concept can be expanded to more lines. Each capture group will store a line if AND only if the lines doesn’t start with 3
#
characters. Then the Replace With field writes them back in reverse order. As some capture groups will be empty there will be nothing to write.The only proviso I have is that there must be (in the current form of the regex) a blank line at the bottom of the file. This allows the last line to be captured as part of a group.
my 2cents worth
Terry -
Hi @Terry-R, All
Clever idea, I like it. And what I like even more is that it is easy to communicate and to apply, just one step, a S/R replacement. My approach isn’t original as well, and it is really complex, as it involves the BetterMultiSelection plugin, Column Editor, and a macro that mechanizes a regex and a sort to reverse the lines.
However, your method has a curious drawback, as you constraint it to only 9 groups. The good news is that there is no reason to stop here.
Don’t know if I’m guessing too much, but I suspect you were misguided by a syntactic issue, as replacements use the backslash
\
. I don’t remember where I learn about it, but it is possible to create up to 99 replacement groups, as long as the dollar$
sign is used in them. Hope I am not wrong about this, @guy038 surely knows all the details.As a test, just add two more groups to the Search field, and enter
($11)($10)$9$8$7$6$5$4$3$2$1
in the Replace box. Worked nice in this sample:### one one one one two two two two three three three three four four four four five five five five six six six six seven seven seven seven eight eight eight eight nine nine nine nine ten ten ten ten eleven eleven eleven eleven ### eleven eleven eleven eleven ten ten ten ten nine nine nine nine eight eight eight eight seven seven seven seven six six six six five five five five four four four four three three three three two two two two one one one one ###
Best Regards
-
@astrosofista said in about selection:
as you constraint it to only 9 groups.
Actually I did mention it could be extended and whilst not entirely familiar with the syntax I am aware of the possibility.
The examples provided only went to 5 or so lines so felt no need to get too complex. As I said a solution had been found and this was partly an exercise in testing my idea as it was different. Possibly it might pay, if OP wants to utilise this idea to first find a method to count max number of lines in any group. That is another question to be answered. I did have a regex which can do it, but it was not elegant.Terry
-
tanxs Terry! your reg-ex work fine for my intent! tanxs so much.
the rest of the discussion went a little off topic … should be moved to a separate post … anyway thanks to everyone for your attention. -
in reality i would just like to invert the first with the last line, in any
###
field -
@cisco779k said in about selection:
in reality i would just like to invert the first with the last line
I’m disappointed, not so much that my solution doesn’t now work as that you have totally changed the problem!
You aren’t the first to pull this stunt and likely won’t be the last but at the moment it is late evening for me so I’m not inclined to bust out my PC just to solve your new problem.Terry
-
Hello, @astrosofista and All,
In a previous post of that discussion, you said :
@guy038, let me ask you a question: how do you create those nice tables? Is a free tool? I’m curious.
Well, in fact, I don’t use any specific tool ! Just the usual column mode editor, with the help, mainly, of
3
characters only :-
The Hythen-Minus sign
-
-
The Equals sign
=
-
The Bullet sign
•
I personally like the Bullet sign because it is exactly vertically centered ;-)) It’s Unicode code-point is
\x{2022}
. Refer to :http://www.unicode.org/charts/PDF/U2000.pdf
Most of the time, you can get it with the keyboard sequence :
-
Hold down the
Alt
key -
Hit, successively, on keys
0
,1
,4
and9
of the numeric keypad -
Release the
Alt
key
Tables composed with that character look better than using the Asterisk sign (
*
) or the Full Stop/Dot char (.
). See, examples below :•---------------•--------------•---------------• *---------------*--------------*---------------* .---------------.--------------.---------------. | LANGUAGE | MAIN form | OTHER forms | | LANGUAGE | MAIN form | OTHER forms | | LANGUAGE | MAIN form | OTHER forms | •---------------•--------------•---------------• *---------------*--------------*---------------* .---------------.--------------.---------------. | bash | sh | bash | | bash | sh | bash | | bash | sh | bash | | | | | | | | | | | | | | c | c | h | | c | c | h | | c | c | h | | c++ | cpp | hpp | | c++ | cpp | hpp | | c++ | cpp | hpp | | c# | cs | | | c# | cs | | | c# | cs | | | CSS | css | | | CSS | css | | | CSS | css | | | | | | | | | | | | | | | DIFF | diff | patch | | DIFF | diff | patch | | DIFF | diff | patch | •---------------•--------------•---------------• *---------------*--------------*---------------* .---------------.--------------.---------------. •===============•==============•===============• *===============*==============*===============* .===============.==============.===============. | LANGUAGE | MAIN form | OTHER forms | | LANGUAGE | MAIN form | OTHER forms | | LANGUAGE | MAIN form | OTHER forms | •===============•==============•===============• *===============*==============*===============* .===============.==============.===============. | bash | sh | bash | | bash | sh | bash | | bash | sh | bash | |---------------•--------------•---------------| |---------------*--------------*---------------| |---------------*--------------*---------------| | c | c | h | | c | c | h | | c | c | h | | c++ | cpp | hpp | | c++ | cpp | hpp | | c++ | cpp | hpp | | c# | cs | | | c# | cs | | | c# | cs | | | CSS | css | | | CSS | css | | | CSS | css | | |---------------•--------------•---------------| |---------------*--------------*---------------| |---------------*--------------*---------------| | DIFF | diff | patch | | DIFF | diff | patch | | DIFF | diff | patch | •===============•==============•===============• *===============*==============*===============* .===============.==============.===============.
Best Regards,
guy038
-
-
Hello, @cisco779k, @Terry-r, @astrosofista, @alan-kilborn and All,
You said in your last post :
in reality i would just like to invert the first with the last line, in any ### field
Then, given the input text below :
pacecececrst$$$! pacecececrst$$$! ### ### peerfergeg4Me<123 ergergerge34r43r343 17ergergom/file/wv7PNHVud9kA ergergerggupload.com/filerge/uU8CesyKVkPb4MWk_0VqkQ/1554th11.7z 1ergergergegQy2iSLvFyoduWHrU 1ergergergegQy2iSLvFyoduWHrUjN7g/1554th18.7zg ergergerggupload.com/filerge 17ergergom/file/wv7PNHVud9kAerAP3_WO-g/1554th0810.7zg ergergerge34r43r343 peerfergeg4Me<123 ### ### pasdcd555ye2018 15o4fkfk4lf,dfmemfgermp 6664lekrflkeuN3s5lmSigp56ove 6664lekrflkeuN3s5lmSigp56oveKPp6w/erferfef3443r3434 15o4fkfk4lf,dfmemfgermp pasdcd555ye2018 ### ### 17ergergom/file/wv7PNHVud9kA ergergerggupload.com/filerge/uU8CesyKVkPb4MWk_0VqkQ/1554th11.7z 1ergergergegQy2iSLvFyoduWHrU 1ergergergegQy2iSLvFyoduWHrUjN7g/1554th18.7zg ### ### paerf3904r903ur3jgj paerf3904r903ur3jgj
The following regex S/R :
SEARCH
(?-s)^(###.+\R)(.+\R)((?:.+\R)*?)(.+\R)(?=^###)
REPLACE
\1\4\3\2
should get your expected text :
pacecececrst$$$! pacecececrst$$$! ### ### ergergerge34r43r343 peerfergeg4Me<123 17ergergom/file/wv7PNHVud9kA ergergerggupload.com/filerge/uU8CesyKVkPb4MWk_0VqkQ/1554th11.7z 1ergergergegQy2iSLvFyoduWHrU 1ergergergegQy2iSLvFyoduWHrUjN7g/1554th18.7zg ergergerggupload.com/filerge 17ergergom/file/wv7PNHVud9kAerAP3_WO-g/1554th0810.7zg peerfergeg4Me<123 ergergerge34r43r343 ### ### 15o4fkfk4lf,dfmemfgermp pasdcd555ye2018 6664lekrflkeuN3s5lmSigp56ove 6664lekrflkeuN3s5lmSigp56oveKPp6w/erferfef3443r3434 pasdcd555ye2018 15o4fkfk4lf,dfmemfgermp ### ### 1ergergergegQy2iSLvFyoduWHrU 1ergergergegQy2iSLvFyoduWHrUjN7g/1554th18.7zg 17ergergom/file/wv7PNHVud9kA ergergerggupload.com/filerge/uU8CesyKVkPb4MWk_0VqkQ/1554th11.7z ### ### paerf3904r903ur3jgj paerf3904r903ur3jgj
Best Regards,
guy038
-
-
@guy038
your reg-ex don’t work…
please read this post! -
Hello, @cisco779k, @Terry-r, @astrosofista, @alan-kilborn and All,
Please, don’t be so rude : I’m only trying to help, freely and I also answer to other people !
You said, previously :
in reality i would just like to invert the first with the last line, in any ### field
and also :
in some cases i also have 9 lines (between ### field)…
But, given the initial text, below, ( which may not respect your logic ! Just an example )
### ### 1234567890 1234567890 17ergergom/file/wv7PNHVud9kA ergergerggupload.com/filerge/uU8CesyKVkPb4MWk_0VqkQ/1554th11.7z 1ergergergegQy2iSLvFyoduWHrU 1ergergergegQy2iSLvFyoduWHrUjN7g/1554th18.7zg 15o4fkfk4lf,dfmemfgermp pasdcd555ye2018 6664lekrflkeuN3s5lmSigp56ove 6664lekrflkeuN3s5lmSigp56oveKPp6w/erferfef3443r3434 pasdcd555ye2018 15o4fkfk4lf,dfmemfgermp 1ergergergegQy2iSLvFyoduWHrU 1ergergergegQy2iSLvFyoduWHrUjN7g/1554th18.7zg 17ergergom/file/wv7PNHVud9kA ergergerggupload.com/filerge/uU8CesyKVkPb4MWk_0VqkQ/1554th11.7z ergergerggupload.com/filerge 17ergergom/file/wv7PNHVud9kAerAP3_WO-g/1554th0810.7zg ergergerge34r43r343 peerfergeg4Me<123 0987676543210 0987676543210 ### ###
after running my regex S/R :
SEARCH
(?-s)^(###.+\R)(.+\R)((?:.+\R)*?)(.+\R)(?=^###)
REPLACE
\1\4\3\2
it does give the expected text :
### ### 0987676543210 0987676543210 17ergergom/file/wv7PNHVud9kA ergergerggupload.com/filerge/uU8CesyKVkPb4MWk_0VqkQ/1554th11.7z 1ergergergegQy2iSLvFyoduWHrU 1ergergergegQy2iSLvFyoduWHrUjN7g/1554th18.7zg 15o4fkfk4lf,dfmemfgermp pasdcd555ye2018 6664lekrflkeuN3s5lmSigp56ove 6664lekrflkeuN3s5lmSigp56oveKPp6w/erferfef3443r3434 pasdcd555ye2018 15o4fkfk4lf,dfmemfgermp 1ergergergegQy2iSLvFyoduWHrU 1ergergergegQy2iSLvFyoduWHrUjN7g/1554th18.7zg 17ergergom/file/wv7PNHVud9kA ergergerggupload.com/filerge/uU8CesyKVkPb4MWk_0VqkQ/1554th11.7z ergergerggupload.com/filerge 17ergergom/file/wv7PNHVud9kAerAP3_WO-g/1554th0810.7zg ergergerge34r43r343 peerfergeg4Me<123 1234567890 1234567890 ### ###
Obviously, the first and last line, made of digits only, are inverted ! So what ?
Best regards,
guy038
-
Hi @guy038, All
Thank you for getting back to me. I am too a big fan of the bullet
•
—the symbol, not the projectile :)—. In my numeric keypad the bullet is typed by the sequence you mentioned and also with justAlt + numpad7
, but as I used it a lot, usually get it through a hotstring, a tripleooo
, which I can easily remember.Concerning your samples, I agree that the bullet looks better than asterisks and dots in ASCII tables. The adding sign
+
also looks fine when used for crossing single lines.I began to see the seemingly next step in tables, the ones constructed with Unicode characters, but I didn´t found the time yet to deal with them.
Well, that’s enough for me and sorry for hijacking the thread.
Best Regards.
-
@Terry-R said in about selection:
find a method to count max number of lines in any group. That is another question to be answered. I did have a regex which can do it, but it was not elegant.
Nice and tricky puzzle. Don’t know if it is elegant or not — another question related to the eye of the beholder —, but found a regex solution for it, a long string of 172 characters for the search expression that matches groups up to 10 lines. Can post it, if interested.
Best Regards.
-
@guy038
I wanted to recall the post, since i didn’t see answers after 2 days and i don’t know how else to contact you. I didn’t want to be rude, it was fair to close the question…well: you have read my post above? with your reply you have published same reg-ex of your previous post.
and not work for me… same reg-ex.
perhaps it is i who do not understand.
now i have this example:### peerfergeg4Me<123 17ergergom/file/wv7PNHVud9kA 1ergergergegQy2iSLvFyoduWHrU ergergerggupload.com/filerge ergergerge34r43r343 ###
this is only 5 line, but on some case i have field to 9 lines.
i want reverse first with last line like this:### ergergerge34r43r343 17ergergom/file/wv7PNHVud9kA 1ergergergegQy2iSLvFyoduWHrU ergergerggupload.com/filerge peerfergeg4Me<123 ###
on this example your reg-ex not work (for me).
-
What I find confusing is that, when asked again, not to take the trouble
to explain exactly where the problem is and what you expect to get as a result.For example your mail from 2 days ago.
You write that in some cases it may be that between the ### lines
can also be 9 lines to be found and give 5 lines as an example. Confuses me.The whole thing suggests that there could be 10 or 15 or only 2 or 3 lines.
You see what I mean?The better and more precise you can ask your question the easier it is for others to help you.
If there are problems with the language, I would use an online translator for what I am doing right now.
They get better and better the more they are used. -
Hello, @cisco779k, @Terry-r, @astrosofista, @alan-kilborn and All,
Oh…, @cisco779k, I’m sorry ! I did not notice the differences between your example, below :
### ergergerge34r43r343 17ergergom/file/wv7PNHVud9kA 1ergergergegQy2iSLvFyoduWHrU ergergerggupload.com/filerge peerfergeg4Me<123 ###
and my example :
### ### ergergerge34r43r343 peerfergeg4Me<123 17ergergom/file/wv7PNHVud9kA ergergerggupload.com/filerge/uU8CesyKVkPb4MWk_0VqkQ/1554th11.7z 1ergergergegQy2iSLvFyoduWHrU 1ergergergegQy2iSLvFyoduWHrUjN7g/1554th18.7zg ergergerggupload.com/filerge 17ergergom/file/wv7PNHVud9kAerAP3_WO-g/1554th0810.7zg peerfergeg4Me<123 ergergerge34r43r343 ### ###
-
In your example, the header string
###
is immediately followed with a line-break -
In mime, the header string
###
is followed with blank chars and an other string###
So the obvious correction to do is to use the following S/R :
SEARCH
(?-s)^(###.*\R)(.+\R)((?:.+\R)*?)(.+\R)(?=^###)
REPLACE
\1\4\3\2
As you see, only the first
+
symbol, of the regex, has been changed into a*
symbol, meaning that string###
, beginning the line (^
), must be followed by0 to n
standard characters (.*
) before the line-break (\R
) !I should have remarked this difference before which would have avoided you to post again ;-))
Best Regards,
guy038
-
-
@guy038 tanxs you so much for your explanation and for modification to your reg-ex!
now it works very well!
I never said I had an example like yours, but maybe it’s my fault that I didn’t explain myself well …
everything is working fine now. always thanks for your regex!
cheers