#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(public|private|protected|static|final|abstract|synchronized|volatile)\s*([\w<>\[\]]+)\s*(\w+)\s*\(([\w\s\w,<>\[\]]*)?\)\s*(\bthrows\b)?[\s\w\s,\w]*\{[\n\t]*(.+)[\n\t]*((return|throw){1}\s*)(\w*)\s*;\s*[\}]"
Local $sString = "public boolean test(String fsdfds)" & @CRLF & _
" {" & @CRLF & _
" boolean boolean = Service.GLP.equals(somevariable.getserviceType());" & @CRLF & _
" return boolean;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
"public static String replaceContentOfFile(String fileContent, String regex, String replace) {" & @CRLF & _
" final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);" & @CRLF & _
" final Matcher matcher = pattern.matcher(fileContent);" & @CRLF & _
" final String result = matcher.replaceAll(replace);" & @CRLF & _
" return result;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
"public boolean test2(String fsdfds)" & @CRLF & _
" {" & @CRLF & _
" boolean boolean = Service.GLP.equals(somevariable.getserviceType());" & @CRLF & _
" return boolean;" & @CRLF & _
" }"
Local $sSubst = ""
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
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 AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm