Skip to main content
Question

Search and remove part string with variable content

  • November 19, 2014
  • 7 replies
  • 65 views

bubblebeb
Contributor
Forum|alt.badge.img+6
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? 

7 replies

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • November 19, 2014
Hi,

 

 

The StringReplacer and a regular expression might help you.

 

Text to Match: \\[.*\\]

 

Replacement Text: <leave blank>

 

Use Regular Expressions: yes

 

 

Takashi

bubblebeb
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • November 19, 2014
Many thanks Takashi

 

Worked a treat. 

bubblebeb
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • November 21, 2014
Takashi

 

 

I have found a glitch with the original data where there can be two sets of [ ] 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 [xxx] and then [yyy] rather than everything from the first open [ and the final ]?

 

 

Thanks

 

Seb 

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • November 22, 2014
Yes, there is. Try this expression.

 

\\[[^\\[\\]]*\\]

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • November 22, 2014
An strange expression. Perhaps you are getting a little confused?

 

.* matches with 0 or more any characters.

 

[^\\[\\]]* matches with 0 or more any characters except [ 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/)

 


Forum|alt.badge.img
  • November 17, 2017
takashi wrote:
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!)

 

 


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • November 17, 2017
jez wrote:
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

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings