Deleting sections.
-
I wish to delete everything not in the []. so from {"start…to },
{“start”:15.95,“end”:18.59,“text”:[“The way you come up like”,“in the defensive line?”]},
What do I need to command?
-
@stuart-benson said in Deleting sections.:
I wish to delete everything not in the []. so from {"start…to }
Firstly your statement doesn’t seem correct given your 1 example line. If you do delete from { to } then you are deleting the very characters you say you want to keep, i.e. the characters within the [ and ] characters.
I’ve decided that what you want is more important than what you want to delete so my solution is as follows.
I think you will find that looking at the problem in reverse it makes it easier to figure out. So instead of saying delete characters not inside the [ and ] characters you can say select/copy everything inside of the [ and ] characters.
So you would use the Mark function with a regular expression search mode using:
Find What:(?-s)\[.+?\]
Click on the “Mark All” which will then highlight all instances. Then use the “Copy Marked Text”. Open a new tab and Ctrl-V to paste the copied text. Problem solved.If this isn’t what you want then you need to provide better explanation and examples. Please read the post at the top of the Help Wanted section titled “Please Read This Before Posting”.
Terry
-
Definitely see HERE!
-
Hello, @stuart-benson, @tery-r, @alan-kilborn and All,
First of all, I suppose that @terry-r, in its post, would have meant :
Find what:
(?-s)\\[.+?\\]
This is one oddity, from our forum, to not interpret the square brakets properly :-(
Not very difficult with regexes ! I assume two hypotheses :
-
There only one zone
{...........}
per line -
Within that zone, there is only one zone
[........]
per line
If so :
-
Open the Replace dialog
Ctrl + H
-
Untick all options
-
SEARCH
(?-s)^\{.+(?=\\[)|(?<=\\]).+$
If you want to KEEP the square brackets
OR
-
SEARCH
(?x-s) ^\{.+\\[|\\].+$
, if you want to DELETE the square brackets, as well -
REPLACE
Leave EMPTY
-
Possibly, tick the
Wrap around
option -
Select the
Regular expression
search mode -
Click on the
Replace All
button
Best Regards,
guy038
-
-
@guy038 said in Deleting sections.:
First of all, I suppose that @terry-r, in its post, would have meant :
Find what: (?-s)[.+?]I did, I did! Darn that posting engine. I thought I had critiqued my post but missed that, sorry @stuart-benson.
Terry
-
I suppose that @terry-r, in its post, would have meant
Darn that posting engine
That’s one of the reasons why I recommend using
\x5B
and\x5D
when doing regexes for literal brackets: it works better in the forum, and it makes it more obvious that it’s searching for a particular character rather than trying to create a regex character class. -
Hi all,
Thank you very much for you reply.
I am sorry I did not put everything up.For some reason, everything is on one line, so after trying what @guy038 suggested (thank you), it didn’t work.
The goal is the keep everything in the square brackets (excluding the "). I do not need anything else, except the text in the square brackets. I do not even need the square brackets.
Again, thank you very much for all your help.
As the line is VERY long, this is a portion of it. Again, I am not sure why it it all on one line when put into Notepad:{“start”:5.76,“end”:6.26,“text”:[“Hi, team.”]},{“start”:6.26,“end”:8.81,“text”:[“We’re looking at”,“our rush defense.”]},{“start”:8.81,“end”:11.51,“text”:[“Today’s session is going to”,“look at our outside alignment,”]},{“start”:11.51,“end”:13.7,“text”:[“and why that’s important”,“for a rush defense.”]},{“start”:13.7,“end”:15.95,“text”:[“OK team, what is an”,“outside alignment?”]},{“start”:15.95,“end”:18.59,“text”:[“The way you come up like”,“in the defensive line?”]},{“start”:18.59,“end”:20.81,“text”:[“How does it relate”,“to an opposition?”]},{“start”:20.81,“end”:23.84,“text”:[“Stand up on the far shoulder”,“from where the ball is.”]},{“start”:23.84,“end”:25.627,“text”:[“Most teams that”,“do a rush defense”]},{“start”:25.627,“end”:27.71,“text”:[“start on that outside”,“shoulder, why do you reckon?”]},{“start”:27.71,“end”:29.485,“text”:[“I think it requires”,“a lot of skill”]},{“start”:29.485,“end”:30.86,“text”:[“from the player”,“catching the ball”]},{“start”:30.86,“end”:32.619,“text”:[“to know what’s”,“going on that side”]},{“start”:32.619,“end”:33.96,“text”:[“if the ball is coming this way.”]},{“start”:33.96,“end”:36.59,“text”:[“So probably that’s why”,“it’s important to step”]},{“start”:36.59,“end”:38.48,“text”:[“on the far shoulder.”]},{“start”:38.48,“end”:40.1,“text”:[“Yeah, I like that.”]},{“start”:40.1,“end”:43.31,“text”:[“it makes that attacker”,“have to use far more skill.”]},{“start”:43.31,“end”:44.33,“text”:[“OK, men.”]},{“start”:44.33,“end”:46.16,“text”:[“So let’s just presume”,“I’m the attacker.”]},{“start”:46.16,“end”:49.31,“text”:[“We’ve got defender”,“1 and defender 2.”]},{“start”:49.31,“end”:51.74,“text”:[“So who’s your man, here?”]},{“start”:51.74,“end”:52.62,“text”:[“Who’s your man, Jay?”]},
-
Hi, @stuart-benson, @terry-r, @alan-kilborn, @peterjones and All,
OK, I see… So, the best option is to use the @terry-r method, as there are several zones
[.........]
: per line :-
Open the Mark dialog (
Ctrl + M
) -
Uncheck all box options
-
SEARCH
(?-s)(?<=\x5B").*?(?="\x5D)
if you use regular quotes"
OR
-
SEARCH
(?-s)(?<=\x5B“).*?(?=”\x5D)
if you use smart quotes“
and”
-
Check the
Purge for each search
andWrap around
options -
Select the
Regular expression
search mode -
Click on the
Mark All
button -
Click on the
Copy Marked Text
button -
Open a new tab (
Ctrl + N
) -
Paste the clipboard’s contents (
Ctrl + V
)
Voila !
You’ll get the expected text :
Hi, team. We’re looking at”,“our rush defense. Today’s session is going to”,“look at our outside alignment, and why that’s important”,“for a rush defense. OK team, what is an”,“outside alignment? The way you come up like”,“in the defensive line? How does it relate”,“to an opposition? Stand up on the far shoulder”,“from where the ball is. Most teams that”,“do a rush defense start on that outside”,“shoulder, why do you reckon? I think it requires”,“a lot of skill from the player”,“catching the ball to know what’s”,“going on that side if the ball is coming this way. So probably that’s why”,“it’s important to step on the far shoulder. Yeah, I like that. it makes that attacker”,“have to use far more skill. OK, men. So let’s just presume”,“I’m the attacker. We’ve got defender”,“1 and defender 2. So who’s your man, here? Who’s your man, Jay?
If your prefer join all these different lines into one line only :
-
Select all these resulting lines (
Ctrl + A
) -
Edit > Line Operations > Join Lines
(Ctrl + J
)
Cheers,
guy038
-