Created
February 7, 2013 17:04
-
-
Save johnnyw66/4732429 to your computer and use it in GitHub Desktop.
Flash to C# Regular Expressions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // sort out some getters and setters for private variables - replace a getter with a C# get and set functions | |
| // We've assumed that were there is a getter - there's also a getter! Remove by unwanted function by hand. | |
| public\s*function\s*get\s*([a-zA-Z]+)\(\s*\)\s*:\s*([^\s]+)\s*{\s*return\s*_[A-Za-z_]+\s*;\s*} | |
| public $2 $1 { get { return _$1 ; } set { _$1 = value ; } } | |
| // remove old Flash setter. FUDGE here - replacing with 1st WhiteSpace we see. | |
| public(\s*)function\s*set\s*([a-zA-Z]+)\([^\)]+\)\s*:\s*void\s*{\s*_[A-Za-z_]+\s*=\s*[^;]+;\s*} | |
| $1 | |
| // sort out return type in | |
| function\s*([A-Za-z_]+)\s*\(([^\)]+)\)\s*:\s*([a-zA-Z_]+) | |
| $3 $1( $2 ) | |
| // Get rid of var in 'var x:int ' statements | |
| ^\s*var\s*([a-zA-Z]+)\s*:\s*([a-zA-Z_]+) | |
| $2 $1 | |
| // sort out remaining Flash vars - be wary of case statement - THIS WILL FAIL IF YOU HAVE MORE THAN ONE WHITESPACE BETWEEN CASE and Switch VAR | |
| (?<!case\s)([a-zA-Z]+)\s*:\s*([a-zA-Z_]+) | |
| $2 $1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment