Remove text between bracket&quote

I need to remove all items in a text document that include brackets with adjoining quotes and all random text in between. ["this is random text that will be removed along with the quotation marks and brackets."]. Brackets without an adjoining quote symbol are not included. [This text will remain along with the brackets.] Any ideas.

In Edit>Find & Replace, tich Regular expressions.

In Find: box, enter \[".+"\]

In Replace: type your replacement text (nothing if you want to erase the match).

Note that text between the brackets must not span a paragraph mark, i.e. the random text is not made of several paragraphs.

@ajlittoz: your regex is greedy … eg. it matches from the first occurence in Paragraph to the last occurence in paragraph.…

better use the ungreedy version \[".+?"\]

@jerryemerydelacruz1: please ensure there only real " doubleqoutes in your Text but NOT typografic Quotes like “…” here

1 Like

Doesn’t work.

@karolus: yes, I had in mind possible nested brackets, but you’re right, in most cases my regexp will eliminate text between "]" and ["` too, which is faulty.

This is the object I’m trying to remove, there are hundreds of them.


“863c64f07e8b09ae27cfcbf537490866”,“1bdc985c254706d078cb3519d0ae2406”,“72441c0f7c123778a806994b572c9d35”,“b20278aa86104259c665ceda23069348”,“1a5adbe1e0530a86071391b6567ae29c”, “c6d06cf3d2d252a5fac9c1afcad11d4c”,“ce4648aa3020d317a6d406b07c149454”,“b0ac643ac4d7252292112e45cff6b4e1”,“e26bee816491aeb419eee524e822669b”,“329f67760e3695650c71fb7224ee43c2”, “e2b88f11c2ada7469373491cf6deb552”,“f63cf63c9f47318f011007f3661e4143”,“82a91cbfcc58152bbb22b6d02ba0f704”,“55e788675b04f14280e97317f964e086”,“7a30500bbede64f6c3e7beacab7968b6”, “72efbc82c47700aff70d26eb858536e9”,“6548050d5305485f42d60efdeeb15351”,“dfb17668d8deb50989fbe521045fe230”,“1e196969137834e82edb46993af45447”,“e639628bc590d223ba9978b7a5204616”]

However, there are objects between brackets that are not in quotations that need to remain.

so may be there are typografic Quotes, try

How to tell the difference?

did you check [x]regular Expression

Yes, I even inserted [“This is a test”] into the document as a test, and the search doesn’t find it.
it cannot, because This is a test is surrounded by typografic quotes, so try again with regex: \[“.+?”\] (copy and paste from here)

It all depends on what causes line breaks. It they are caused by line wrap or line breaks (Shift+Enter), the regexp should word. But if they are paragraph breaks, no luck, Find & Replace is limited to a paragraph contents.

To know which is used, enable View>Formatting Marks. Paragraph marks are displayed ¶ while line breaks are ↲.

It looks like your data comes from some computer output. You’d be better off with a specialised tool like awk or m4 to pre-process the plain text file before pasting it into Writer.

If it is too late (text is already in Writer or you can’t “comfortably” restore the rest of the text), you may have styled specially this sort of data. Remember that styling purpose is to mark up semantically your text. Typographical appearance comes later as a decoration for semantics. Then if your document is “correctly” styled, Find & Replace can eliminate all paragraphs with a given style.

1 Like

I’ve resized the font to see if the line returns are in the text or wrapped. There are hard line breaks between brackets, but they are not indented as a paragraph would be. In either case, the search fails to find the test I inserted that doesn’t have a paragraph or line break.

Your screenshot clearly shows you have typographical quotes in your test case, not straight quotation marks.

There are paragraphs in the text. I can remove the paragraphs but the syntax doesn’t catch the test pattern.

Removing the paragraphs is a tedious manual process. You can then manually remove the data instead.

Removing paragraph markers is done with the $ sign, I can replace the paragraph markers easily. But the syntax doesn’t catch the test pattern, so until the test pattern is recognized, there’s no point in replacing the paragraph markers.

I remember it is possible to remove the paragraph marks by search and replace but have to look up the details…

Your test failed because of other quotation marks, or it would have worked.

In your original data it failed because of the paragraph marks…

The $ sign is the syntax to find a paragraph in the writer search box.

So how to make it work with the quotation marks given?

so try again with regex: \[“.+?”\] (copy and paste the pattern from here)