# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"\s+TStatusBar"
test_str = ("inherited FormPadrao: TFormPadrao\n"
" Left = 354\n"
" Top = 155\n"
" Caption = 'FormPadrao'\n"
" ClientHeight = 342\n"
" ClientWidth = 655\n"
" KeyPreview = True\n"
" PopupMenu = MnPop_Principal\n"
" OnCloseQuery = FormCloseQuery\n"
" OnDeactivate = FormDeactivate\n"
" ExplicitWidth = 671\n"
" ExplicitHeight = 381\n"
" DesignSize = (\n"
" 655\n"
" 342)\n"
" PixelsPerInch = 96\n"
" TextHeight = 15\n"
" object Bv_Top: TBevel [0]\n"
" Left = 0\n"
" Top = 0\n"
" Width = 655\n"
" Height = 2\n"
" Align = alTop\n"
" end\n"
" object Sb_FormPadrao: TStatusBar [1]\n"
" Left = 0\n"
" Top = 317\n"
" Width = 655\n"
" Height = 25\n"
" Panels = <\n"
" item\n"
" Bevel = pbNone\n"
" Text = 'Usu'#225'rio'\n"
" Width = 100\n"
" end\n"
" item\n"
" Bevel = pbNone\n"
" Width = 50\n"
" end>\n"
" ParentColor = True\n"
" ParentFont = True\n"
" UseSystemFont = False\n"
" ExplicitTop = 323\n"
" end\n"
" object Pn_BaseToolBar: TPanel [2]\n"
" Left = 0\n"
" Top = 2\n"
" Width = 655\n"
" Height = 73\n"
" Align = alTop\n"
" BevelOuter = bvNone\n"
" ParentColor = True\n"
" TabOrder = 2\n"
" end\n"
" object Pn_BaseGrid: TPanel [3]\n"
" Left = 0\n"
" Top = 75\n"
" Width = 655\n"
" Height = 242\n"
" Align = alClient\n"
" BevelOuter = bvNone\n"
" BorderWidth = 3\n"
" ParentColor = True\n"
" TabOrder = 4\n"
" ExplicitLeft = 32\n"
" ExplicitTop = 95\n"
" ExplicitHeight = 222\n"
" end\n"
" inherited MinMax: TmgMinMax\n"
" Top = 7\n"
" MinTrackSize.X = 450\n"
" MinTrackSize.Y = 300\n"
" ExplicitTop = 7\n"
" end\n"
" object Mn_Principal: TMainMenu [6]\n"
" Left = 4\n"
" Top = 36\n"
" object miTabela: TMenuItem\n"
" Caption = '&Tabela'\n"
" object miInserir: TMenuItem\n"
" Caption = '&Inserir'\n"
" end\n"
" object miApagar: TMenuItem\n"
" Caption = '&Apagar'\n"
" end\n"
" object miPropriedades: TMenuItem\n"
" Caption = '&Editar'\n"
" end\n"
" object N4: TMenuItem\n"
" Caption = '-'\n"
" end\n"
" object miFechar: TMenuItem\n"
" Caption = '&Fechar'\n"
" OnClick = miFecharClick\n"
" end\n"
" end\n"
" object miEditar1: TMenuItem\n"
" Caption = '&Editar'\n"
" object miRecortar1: TMenuItem\n"
" Caption = '&Recortar'\n"
" end\n"
" object miCopiar1: TMenuItem\n"
" Caption = '&Copiar'\n"
" end\n"
" object miColar1: TMenuItem\n"
" Caption = '&Colar'\n"
" end\n"
" end\n"
" object miExibir: TMenuItem\n"
" Caption = '&Exibir'\n"
" object miBarradeFerramentas: TMenuItem\n"
" Caption = 'Barra de &Ferramentas'\n"
" object miNaoExibir: TMenuItem\n"
" Caption = '&N'#227'o Exibir'\n"
" GroupIndex = 1\n"
" RadioItem = True\n"
" OnClick = mi_NaoExibirClick\n"
" end\n"
" object N5: TMenuItem\n"
" Caption = '-'\n"
" GroupIndex = 1\n"
" RadioItem = True\n"
" end\n"
" object miAlto: TMenuItem\n"
" Caption = '&Alto'\n"
" GroupIndex = 1\n"
" RadioItem = True\n"
" OnClick = mi_AltoClick\n"
" end\n"
" object miBaixo: TMenuItem\n"
" Caption = '&Baixo'\n"
" GroupIndex = 1\n"
" RadioItem = True\n"
" OnClick = mi_BaixoClick\n"
" end\n"
" end\n"
" object miBarradeStatus: TMenuItem\n"
" Caption = 'Barra de &Status'\n"
" OnClick = mi_BarradeStatusClick\n"
" end\n"
" object mi_SepN3: TMenuItem\n"
" Caption = '-'\n"
" end\n"
" object mi_Informacoesdajanela1: TMenuItem\n"
" Caption = 'Informa'#231#245'es desta Janela'\n"
" OnClick = mi_Informacoesdajanela1Click\n"
" end\n"
" object mi_Sepm9: TMenuItem\n"
" Caption = '-'\n"
" Visible = False\n"
" end\n"
" object mi_OcorrenciaAuditoria: TMenuItem\n"
" Caption = 'Logs de Auditoria'\n"
" Visible = False\n"
" OnClick = mi_OcorrenciaAuditoriaClick\n"
" end\n"
" end\n"
" object Mi_Ajuda: TMenuItem\n"
" Caption = '&Ajuda'\n"
" object Mi_AjudaProcesso: TMenuItem\n"
" Caption = 'Ajuda &Processo'\n"
" ShortCut = 112\n"
" OnClick = Mi_AjudaProcessoClick\n"
" end\n"
" object Mi_AjudaTela: TMenuItem\n"
" Caption = 'Ajuda &Tela'\n"
" ShortCut = 16496\n"
" OnClick = Mi_AjudaTelaClick\n"
" end\n"
" object Mi_HistoricoAlteracoes: TMenuItem\n"
" Caption = '&Hist'#243'rico de altera'#231#245'es'\n"
" Visible = False\n"
" OnClick = Mi_HistoricoAlteracoesClick\n"
" end\n"
" end\n"
" end\n"
" inherited mgPopupImpressao: TmgPopupMenu\n"
" Left = 4\n"
" end\n"
" object MnPop_Principal: TPopupMenu\n"
" Left = 34\n"
" Top = 36\n"
" object mi_Inserir: TMenuItem\n"
" Caption = '&Inserir'\n"
" end\n"
" object mi_Apagar: TMenuItem\n"
" Caption = '&Apagar'\n"
" end\n"
" object mi_Editar: TMenuItem\n"
" Caption = '&Editar'\n"
" end\n"
" object N1: TMenuItem\n"
" Caption = '-'\n"
" end\n"
" object mi_BarradeFerramentas: TMenuItem\n"
" Caption = '&Barra de Ferramentas'\n"
" object mi_NaoExibir: TMenuItem\n"
" Caption = '&N'#227'o Exibir'\n"
" GroupIndex = 1\n"
" RadioItem = True\n"
" OnClick = mi_NaoExibirClick\n"
" end\n"
" object N2: TMenuItem\n"
" Caption = '-'\n"
" GroupIndex = 1\n"
" RadioItem = True\n"
" end\n"
" object mi_Alto: TMenuItem\n"
" Caption = '&Alto'\n"
" GroupIndex = 1\n"
" RadioItem = True\n"
" OnClick = mi_AltoClick\n"
" end\n"
" object mi_Baixo: TMenuItem\n"
" Caption = '&Baixo'\n"
" GroupIndex = 1\n"
" RadioItem = True\n"
" OnClick = mi_BaixoClick\n"
" end\n"
" end\n"
" object mi_BarradeStatus: TMenuItem\n"
" Caption = 'Ba&rra de Status'\n"
" OnClick = mi_BarradeStatusClick\n"
" end\n"
" end\n"
"end")
subst = " TMgStatusBar"
# You can manually specify the number of replacements by changing the 4th argument
result = re.sub(regex, subst, test_str, 1, re.IGNORECASE)
if result:
print (result)
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html