Skip to main content
I have a spreadsheet with lines of names and addresses which have comments by the author in square brackets in the names. e.g. Eon Energy [formerly Powergen].

 

I want to be able to search for and remove everything in the square brackets (and the brackets themselves). 

 

Does anyone know how to do this? 
Hi,

 

 

The StringReplacer and a regular expression might help you.

 

Text to Match: \\ .*\\]

 

Replacement Text: <leave blank>

 

Use Regular Expressions: yes

 

 

Takashi
Many thanks Takashi

 

Worked a treat. 
Takashi

 

 

I have found a glitch with the original data where there can be two sets of f ] in the string. This RegEx removes both sets and everthing in between. 

 

Is there a way of changing the RegEx to remove everything in the txxx] and then hyyy] rather than everything from the first open p and the final ]?

 

 

Thanks

 

Seb 
Yes, there is. Try this expression.

 

\\\[^\\\\\]]*\\]
An strange expression. Perhaps you are getting a little confused?

 

.* matches with 0 or more any characters.

 

p^\\\\\]]* matches with 0 or more any characters except t and ].

 

/ and ] are special characters to define a character class in regular expressions, so you will have to escape them with a backslash if you use them in an expression as the character itself.

 

See also here to learn more about regular expressions.

 

Regular-Expressions.info  (http://www.regular-expressions.info/)

 


Yes, there is. Try this expression.

 

\\\[^\\\\\]]*\\]
Hello Takashi. I have a similar issue to the one you resolved here but in mine the string contains data as formatted as : (77) (53.3) (5.33)

 

I wish to extract the data into three new attributes where Attribute1 = 77, Attribute2 =53.3 and Attribute3 = 5.33.

 

To add a level of complexity the number of digits and the place of the decimal point can vary within the rows of data.

 

Please can you advise (I'm no expert!)

 

 


Hello Takashi. I have a similar issue to the one you resolved here but in mine the string contains data as formatted as : (77) (53.3) (5.33)

 

I wish to extract the data into three new attributes where Attribute1 = 77, Attribute2 =53.3 and Attribute3 = 5.33.

 

To add a level of complexity the number of digits and the place of the decimal point can vary within the rows of data.

 

Please can you advise (I'm no expert!)

 

 

Hi @jez, I added a comment to this thread.

 

How to expose the charters held within parentheses

 


Reply