Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string = '''
- def testFunction(a, b):
- print("hello world")
- def _privateFunc(a):
- pass
- def __protectedFunc(a):
- pass
- '''
- # string = re.sub(r"(?P<blockIndent>[ ]*)def[ ]*__(?P<functionName>[a-zA-Z0-9_])(?P<funcParams>[\s\S]+)[ ]*:[\r\n]+(?P<body>(?P<indent>[ ]+)[^\r\n]+[\r\n]+((?P=indent)[^\r\n]+[\r\n]+)*)",
- # r'\g<blockIndent>protected void \g<functionName>\g<funcParams>{\n\g<body>\g<blockIndent>}\n', string)
- # string = re.sub(r"(?P<blockIndent>[ ]*)def[ ]*_(?P<functionName>[a-zA-Z0-9_])(?P<funcParams>[\s\S]+)[ ]*:[\r\n]+(?P<body>(?P<indent>[ ]+)[^\r\n]+[\r\n]+((?P=indent)[^\r\n]+[\r\n]+)*)",
- # r'\g<blockIndent>private void \g<functionName>\g<funcParams>{\n\g<body>\g<blockIndent>}\n', string)
- string = re.sub(r"(?P<blockIndent>[ ]*)def[ ]*(?P<functionName>[a-zA-Z0-9_]+)\((?P<firstParam>[\s\S]+)(?P<other>[\s\S]+)\)[ ]*:",
- r"\g<blockIndent>def \g<functionName>(Object \g<firstParam>, \g<other>):", string)
- string = re.sub(r"(?P<blockIndent>[ ]*)def[ ]*(?P<functionName>[a-zA-Z0-9_]+)\((?P<firstParam>(?<!Object)[^,][\s\S]+)(?P<other>[\s\S]+)\)[ ]*:",
- r"\g<blockIndent>def \g<functionName>(Object \g<firstParam>, \g<other>):", string)
- # string = re.sub(r"(?P<blockIndent>[ ]*)def[ ]*(?P<functionName>[a-zA-Z0-9_])(?P<funcParams>[\s\S]+)[ ]*:[\r\n]+(?P<body>(?P<indent>[ ]+)[^\r\n]+[\r\n]+((?P=indent)[^\r\n]+[\r\n]+)*)",
- # r'\g<blockIndent>public void \g<functionName>\g<funcParams>{\n\g<body>\g<blockIndent>}\n', string)
- print(string)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement