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.

This post was flagged by the community and is temporarily hidden.

@wajid Enter this regular expression \[.+?\] in the Find: box and nothing in the Replace: box. You may optionally add spaces or tilde around the bracketed sequence to remove them as well, something like ~?\s*\[.+?\]\s* but in this case I recommend the Replace: box contains a space. Don’t forget to tick the Regular expression check box.

1 Like

not working data in [ ] and that date and time

@wajid
You’re trying the wrong place!




Find & Replace

1 Like

Thank you sir done

sir
can we change specific name color size ,
and how to enter “enter” after a specific name . . . .
thanks a a lot

Do you want to change colour and font size while you remove text between quotes? IMHO, it is much better to apply a specific custom character style on the target sequences. This gives you reliability and versatility.
I don’t understand your request to change “specific name” unless you mean applying typographical attributes on any word. In this case, this is not related to removing text, but my suggestion above remains valid: apply a character style.

Do it manually. Use the Find function to find the “name” and press Enter for a paragraph break or Shift+Enter for a line break. They are not equivalent. Generally you want a paragraph break.

This addition can’t be done with built-in Edit>Find & Replace because its range is limited to a paragraph contents. Macro users may propose solution but it seems to me overkill if you have only a handful of additions.

1 Like

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.

1 Like

@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

2 Likes

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.

[“347d23f1bb0da62618b6697874ee1f44”,“007d313d1ec38fdd1a1301652964d892”,“29279a336402408d6e65eab24f462d1d”,“adc6ec7131f8839b2d4e73b52a599dd9”,“c67454cd35a562a4616e5f3ecf1b1f0f”,

“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.