Created
June 10, 2010 23:58
-
-
Save osima/433835 to your computer and use it in GitHub Desktop.
{key:value} スタイル表記のマクロプロセッサ
This file contains 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
// | |
// {key:value} スタイル表記のマクロプロセッサ | |
// | |
import java.util.regex.Pattern | |
class MacroProcessor { | |
static def PAT = Pattern.compile('\\{(.+?):(.*?)\\}'); | |
def text | |
def MacroProcessor(String text){ | |
this.text = text | |
} | |
def hasMacro(){ | |
def m = PAT.matcher(text) | |
if( m.find() ) | |
return true | |
return false | |
} | |
String getKey(){ | |
def m = PAT.matcher(text) | |
if( m.find() ) | |
return m.group(1) | |
return null | |
} | |
def getValue(){ | |
def m = PAT.matcher(text) | |
if( m.find() ) | |
return m.group(2) | |
return null | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment