How to find a text inside a file with Regular Expression

Asked

Viewed 78 times

0

Good morning

I need to create a script to normalize some DFM type files (Delphi form file) where I need to change the expression Commandtext to SQL.Text and whatever you have after = stay ()

  object QrUsuario: TSQLDataSet
    CommandText = 
      'select USUARIO_ATIVO, USUARIO_NOME, fdsafdsa143 34112 USUARIO_SENHA from TABELA_US' +
      'UARIO'
    MaxBlobSize = -1
    Params = <>
    SQLConnection = DbDados
    Left = 451
    Top = 80
  end

The problem happens when you have line break as in the example above. If you have the same line it worked when using the script:

(CommandText) += ('.+')

But the break is not found.

To delimit the text you have to start and end with ' Does anyone have any suggestions?

I tried to use that expression, too, but then she won’t stop:

(CommandText) += \s*('[\s\r\n\w\+\'\"\#\!\@\$\%\&\*\(\)\_\-\=\[\]\{\}\?\;\:\.\,\\\|\<\>\/]+')

1 answer

0

The command that worked was this:

CommandText = ((\s*'.*'|\s+\+)*)

It resulted in the matchabaixo:

CommandText = 'select USUARIO_ATIVO, USUARIO_NOME, USUARIO_SENHA from TABELA_US' + 
              'UARIO'

With group 1 with the value:

  'select USUARIO_ATIVO, USUARIO_NOME, USUARIO_SENHA from TABELA_US' +
  'UARIO'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.