-2

I'm porting my system to another data access library. For that, I'm using regex to replaces/remove some codes on my source. (A example above)

I need to remove everything between IBOQ_OrderingItems.Strings and ') by regex. But I can't write a regex to express this condition to express that. In my attempts, this does not recognize something like #180'asdf' or 'adsf (asdf) asdf' or ' adf '. When recognized, the regexp delete all content of file.

object SQLCalcula_umaLinha: TFDQuery
    IBOQ_OrderingItems.Strings = (
      'sf')
  end
  object SQLCalcula_VariasLinhas: TFDQuery
    IBOQ_OrderingItems.Strings = (
      'sfdf'
      'sdffs'
      'sf')   
  end
  object SQLCalcula_parentesesNoMeio: TFDQuery
    IBOQ_OrderingItems.Strings = (
      'sfdf'
      'sdffs ('' asdf '')'
      'sf')
  end
Thomas Ayoub
  • 29,063
  • 15
  • 95
  • 142
  • This needs an MCVE - see http://stackoverflow.com/help/mcve. Amongst other things, you don't say which regex library you're using, and you haven't shown your regex or code that uses it. – MartynA Jan 18 '17 at 19:34
  • I'm sorry. My English is terrible. I don't communicate very well in English. Any way, I was found a solution to my question and have posted down. – Francisco Thiago Jan 19 '17 at 15:50

2 Answers2

0

I found a solution:

IBOQ_.*.Strings.=.\((\s.[\w|\s|('|')|@|!|$|#||&|*|<|>|=|*|~]*.)+'\)

I hope to help :)

0

Or you could try something like

IBOQ_.*\.Strings\s*=\s*\((?:'[^']*'|[^)])*\)

which does it in 288 steps instead of yours, that does it in 48067 steps ;)

Check it out here at regex101.

Edit Changed to handle parentheses inside quotes.

SamWhan
  • 8,296
  • 1
  • 18
  • 45
  • the last group is wrong. The selection doesn't apply to last 'sf') ` object SQLCalcula_parentesesNoMeio: TFDQuery IBOQ_OrderingItems.Strings = ( 'sfdf' 'sdffs ('' asdf '')' 'sf') end ` – Francisco Thiago Jan 19 '17 at 18:39