Jump to content

Some RegExpReplace Questions


Recommended Posts

Trying to filter out some code: I am trying to write a regexpreplace line that will remove everything between ()

Simple question but nothing I try seems to work

Edited by floodge
Link to comment
Share on other sites

Without seeing the lines you are actually working with this will be a guess at best.

$sRtn  = StringRegExpReplace($sStr, "(.*\().*(\).*)", "$1$2")

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

#include <Array.au3>

Dim $sStr = '#include <GUIConstantsEx.au3>' & @CRLF & _
            '#include <WindowsConstants.au3>' & @CRLF & _
            "Opt('MustDeclareVars', 1)" & @CRLF & _
            'Example1()' & @CRLF & _
            'Example2()' & @CRLF & @CRLF & _
            '; example 1' & @CRLF & _
            'Func Example1()' & @CRLF & _
            '   Local $msg' & @CRLF & @CRLF & _
            '   GUICreate("My GUI") ; will create a dialog box that when displayed is centered' & @CRLF & _
            '   GUISetState(@SW_SHOW) ; will display an empty dialog box' & @CRLF & @CRLF & _
            '   ; Run the GUI until the dialog is closed' & @CRLF & _
            '   While 1' & @CRLF & _
            '       $msg = GUIGetMsg()' & @CRLF & @CRLF & _
            '       If $msg = $GUI_EVENT_CLOSE Then ExitLoop' & @CRLF & _
            '   WEnd' & @CRLF & _
            '   GUIDelete()' & @CRLF & _
            'EndFunc   ;==>Example1' & @CRLF & @CRLF & _
            '; example 2' & @CRLF & _
            'Func Example2()' & @CRLF & _
            '   Local $gui, $background, $pic, $basti_stay, $msg' & @CRLF & _
            '   Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\logo4.gif"' & @CRLF & @CRLF & _
            '   $gui = GUICreate("Background", 400, 100)' & @CRLF & _
            '   ; background picture' & @CRLF & _
            '   $background = GUICtrlCreatePic(@SystemDir & "\oobe\images\mslogo.jpg", 0, 0, 400, 100)' & @CRLF & _
            '    GUISetState(@SW_SHOW)' & @CRLF & @CRLF & _
            '   ; transparent MDI child window' & @CRLF & _
            '   $pic = GUICreate("", 169, 68, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $gui)' & @CRLF & _
            '   ; transparent pic' & @CRLF & _
            '   $basti_stay = GUICtrlCreatePic($sFile, 0, 0, 169, 68)' & @CRLF & _
            '   GUISetState(@SW_SHOW)' & @CRLF & @CRLF & _
            '   Do' & @CRLF & _
            '       $msg = GUIGetMsg()' & @CRLF & _
            '   Until $msg = $GUI_EVENT_CLOSE' & @CRLF & _
            'EndFunc   ;==>Example2'
            
Dim $aMatch = StringRegExp($sStr, '\((?:(?>[^()]*)|(?R))*\)', 3)
If IsArray($aMatch) Then _ArrayDisplay($aMatch)
$sStr = StringRegExpReplace($sStr, '\((?:(?>[^()]*)|(?R))*\)', '()')
ConsoleWrite($sStr & @LF)

Edited by Authenticity
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...