input sample.inp
name=John
quantity=23
Hello $name,
You will have 23 boxes.
Thanks
output
Hello John,
You will have 23 boxes.
Thanks
jflex
/**
copy as java comment
*/
%%
%public
%class ClassName
//%debug
%standalone
%unicode
%{
String name;
String quantity;
%}
%%
"name=" [a-zA-Z]+
{
name = yytext().substring(5);
}
"quantity=" [0-9]+
{
quantity = yytext().substring("quantity=".length());
}
"$name" { System.out.print(name); }
"$quantity" { System.out.print(quantity); }
jflex simple.flex
javac ClassName
java ClassName sample.inp