Add getters and setters to a set of variables
You forgot the parameter type in the setter methods (including @blufox suggestion):

sed -r "s/private\s+([^; ]+)\s+([^; ]+)\s*;(.*)$/&amp;\npublic \1 get\u\2(){return \2;}\npublic void set\u\2(\1 \2){this.\2=\u\2;}\n/" "%~1"&gt;"%~2"


which produces:

private String firstName;// Stores firstName
public String getFirstName(){return firstName;}
public void setFirstName(String firstName){this.firstName=FirstName;}


But: you better use an IDE (e.g., Eclipse) for these tasks. You are trying to parse Java code with a regex which is a bad idea.

Just some examples:


declarations could be on different lines

private String // some comment
    myVariableOnTheNextLine
    // some other comment
    ; // semicolon

the public or private modifier could be omitted

String myString;

fields can be initialized

String myString = "my string";

fields can be declared final

private final String myString;

and so on