Skip to content

Instantly share code, notes, and snippets.

@osima
Created June 10, 2010 23:58
Show Gist options
  • Save osima/433835 to your computer and use it in GitHub Desktop.
Save osima/433835 to your computer and use it in GitHub Desktop.
{key:value} スタイル表記のマクロプロセッサ
//
// {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