Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace characters only in headings

I have several files (see the Input section), what I need it to strip [[ ]] with REGEX, but the problem is that only for:

- # headings
- >quotes

All other brackets should be preserved. I cannot make it thru... I'm using the sublime reader. If anybody have some ideas I will really appreciate it! Thanks

Input


## [[zoom]] _[v]_

>[[move]] | [[very]] | [[quickly]]

__Synonyms__: [[buzz]] | [[dart]] | [[dash]] | [[dive]] | [[flash]] | [[fly]] | [[hum]] | [[hurtle]] | outstrip | [[rip]] | [[rocket]] | [[rush]] | [[shoot]] | [[shoot]] up | [[skyrocket]] | [[speed]] | [[streak]] | [[surge]] | [[tear]] | [[whirl]] | [[whiz]] | [[zip]]

__Concepts__: [[ACTIONS - MOTION#move oneself quickly (150)\|move oneself quickly]] 

__Antonyms__: decelerate, [[slow]]

## [[zip]] _[n]_

>[[enthusiasm]], [[energy]]

__Synonyms__: brio | [[drive]] | [[get]]-upand-[[go]] | [[go]] | [[gusto]] | [[life]] | liveliness | [[oomph]] | [[pep]] | [[pizzazz]] | [[punch]] | [[sparkle]] | [[spirit]] | [[verve]] | [[vigor]] | vim | [[vitality]] | [[zest]] | [[zing]]

__Concepts__: [[LIFE FORMS - GENERAL CHARACTERISTICS#personality (411)\|personality]], [[STATES - ABSTRACT#behavior (633)\|behavior]] 

__Antonyms__: [[apathy]], enervation, [[idleness]], [[laziness]], [[lethargy]]
 
## [[zip]] _[v]_

>[[move]] | [[about]] | [[quickly]]

__Synonyms__: [[bustle]] | [[dash]] | [[flash]] | [[fly]] | [[hasten]] | [[hurry]] | [[run]] | [[rush]] | [[shoot]] | [[speed]] | [[tear]] | waltz | [[whisk]] | [[whiz]] | [[zoom]]

__Concepts__: [[ACTIONS - MOTION#move oneself quickly (150)\|move oneself quickly]] 

__Antonyms__: decelerate, [[slow]]

Output


## zoom _[v]_

>move very quickly

__Synonyms__: [[buzz]] | [[dart]] | [[dash]] | [[dive]] | [[flash]] | [[fly]] | [[hum]] | [[hurtle]] | outstrip | [[rip]] | [[rocket]] | [[rush]] | [[shoot]] | [[shoot]] up | [[skyrocket]] | [[speed]] | [[streak]] | [[surge]] | [[tear]] | [[whirl]] | [[whiz]] | [[zip]]

__Concepts__: [[ACTIONS - MOTION#move oneself quickly (150)\|move oneself quickly]] 

__Antonyms__: decelerate, [[slow]]

## zip _[n]_

>enthusiasm, energy

__Synonyms__: brio | [[drive]] | [[get]]-upand-[[go]] | [[go]] | [[gusto]] | [[life]] | liveliness | [[oomph]] | [[pep]] | [[pizzazz]] | [[punch]] | [[sparkle]] | [[spirit]] | [[verve]] | [[vigor]] | vim | [[vitality]] | [[zest]] | [[zing]]

__Concepts__: [[LIFE FORMS - GENERAL CHARACTERISTICS#personality (411)\|personality]], [[STATES - ABSTRACT#behavior (633)\|behavior]] 

__Antonyms__: [[apathy]], enervation, [[idleness]], [[laziness]], [[lethargy]]
 
## zip _[v]_

>move about quickly

__Synonyms__: [[bustle]] | [[dash]] | [[flash]] | [[fly]] | [[hasten]] | [[hurry]] | [[run]] | [[rush]] | [[shoot]] | [[speed]] | [[tear]] | waltz | [[whisk]] | [[whiz]] | [[zoom]]

__Concepts__: [[ACTIONS - MOTION#move oneself quickly (150)\|move oneself quickly]] 

__Antonyms__: decelerate, [[slow]]
like image 952
dxc Avatar asked Feb 10 '21 05:02

dxc


People also ask

How does find and replace feature help us?

What Is Find and Replace. Find and Replace is a function in Word that allows you to search for target text (whether it be a particular word, type of formatting or string of wildcard characters) and replace it with something else.


1 Answers

In sublime text editor you can use PCRE flavor of regex. Following should work for you.

Search regex:

(?:^[#>]|(?!^)\G).*?\K(?:\[\[|]])

Replace with an empty string.

RegEx Demo

RegEx Details:

  • (?:: Start non-capture group
    • ^[#>]: Match # or > at the start
    • |: OR
    • (?!^)\G: Restart matching from end of the previous match
  • ): End non-capture group
  • .*?: Match 0 or more of any character (lazy)
  • \K: Reset match info
  • (?:\[\[|]]): Match [[ or ]]
like image 64
anubhava Avatar answered Oct 03 '22 23:10

anubhava