Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Replace variable length bracketed string
#1
I am trying to replace all occurences of a bracketed string with sometimes nothing and sometimes something else and I cannot work out how to refer to the brackets themselves (or how to select variable length text between).

An extract from one of the files (musicians) is:
Hall, Ben + Ruppersberg, Don + Robertson, Bill (trombone); Kinsey, Gene (alto sax); McCook, Don (alto sax, clarinet)
I want to reformat this as:
Hall, Ben + Ruppersberg, Don + Robertson, Bill; Kinsey, Gene; McCook, Don

I tried your excellent and elegant:

key Ca
Replace "xxx" "yyy" 0 1 1

and it works brilliantly for known text substitution, but I cannot get it to select the brackets.
So replace "trombone" with "guitar" works but replace "(trombone)" with "" - ie nothing - does not because it rejects the opening bracket "(".
And what I really want to do is replace the brackets "()" and all the text between each with nothing (or sometimes a constant text string).

All help gratefully received!

Terry
#2
Use regular expression.

key Ca
Replace " \(.+?\)" "" 0 0 0 1
#3
Wow Gintaras, you are a star! Works brilliantly. Thank you so much for quick reply, much appreciated..

Terry


Forum Jump:


Users browsing this thread: 3 Guest(s)