Index: other-projects/trunk/anttasks/build.xml
===================================================================
--- other-projects/trunk/anttasks/build.xml	(revision 18596)
+++ other-projects/trunk/anttasks/build.xml	(revision 18960)
@@ -84,4 +84,16 @@
 		</rsr>
 
+		<!-- test 6 -->
+		<copy file="src/test/rsr.txt" tofile="test/rsr6-1.txt"/>
+		<copy file="src/test/rsr.txt" tofile="test/rsr6-2.txt"/>
+		<copy file="src/test/rsr.txt" tofile="test/rsr6-3.txt"/>
+		<copy file="src/test/rsr.txt" tofile="test/rsr6-4.txt"/>
+		<rsr file="test/rsr6-1.txt" pattern="e" replacement="*" lines="8"/>
+		<rsr file="test/rsr6-2.txt" pattern="e" replacement="*" lines="4-9"/>
+		<rsr file="test/rsr6-3.txt" pattern="e" replacement="*" lines="-8"/>
+		<rsr file="test/rsr6-4.txt" pattern="e" replacement="*" lines="4-"/>
+
+
+
 
 	</target>
Index: other-projects/trunk/anttasks/src/org/greenstone/anttasks/RegexSearchReplace.java
===================================================================
--- other-projects/trunk/anttasks/src/org/greenstone/anttasks/RegexSearchReplace.java	(revision 18596)
+++ other-projects/trunk/anttasks/src/org/greenstone/anttasks/RegexSearchReplace.java	(revision 18960)
@@ -37,4 +37,6 @@
 	private String pattern = null;
 	private String replacement = null;
+	private int fromLine = -1;
+	private int toLine = -1;
 	private boolean winPath = false;
 
@@ -45,4 +47,5 @@
 		rsr.setPattern(args[1]);
 		rsr.setReplacement(args[2]);
+		rsr.setLines(args[3]);
 
 		rsr.execute();
@@ -119,16 +122,9 @@
 		System.out.println();
 
-		//output filename(s)
-		/*
-		if ( file != null ) {
-			System.out.println( "Replace in file: " + file );
-		} else {
-			System.out.println( "Replace in files:" );
-			for ( int i = 0; i < files.length; i++ ) {
-				System.out.println(files[i]);
-			}
-		}
-		*/
-
+		//output lines if necessary
+		if ( this.fromLine != -1 || this.toLine != -1 ) {
+			System.out.println( "Lines: " + (this.fromLine==-1?"Start":this.fromLine) + " ~ " + (this.toLine==-1?"End":this.toLine) );
+			System.out.println();
+		}
 
 		System.out.println( "Files: " );
@@ -168,4 +164,5 @@
 			//pass the file through, searching and replacing
 			String line = null;
+			int lineNumber = 1;
 			boolean hasMoreLines = true;
 			while ( hasMoreLines ) {
@@ -182,23 +179,26 @@
 				} else {
 
-					String oldLine = line;
-					if ( pattern != null ) {
-						String rp = replacement;
-						if ( winPath ) {
-							rp = rp.replaceAll("\\\\","\\\\\\\\");
-						}
-						line = line.replaceAll((String)pattern, (String)rp);
-					} else {
-						for ( int i=0; i<jobs.size(); i++ ) {
-							String rp = ((RegexSearchReplaceJob)(jobs.get(i))).getReplacement();
-							if ( ((RegexSearchReplaceJob)(jobs.get(i))).getWinPath() ) {
+					//only if within the given line range
+					if ( ( fromLine == -1 || lineNumber >= fromLine ) && ( toLine == -1 || lineNumber < toLine ) ) {
+						String oldLine = line;
+						if ( pattern != null ) {
+							String rp = replacement;
+							if ( winPath ) {
 								rp = rp.replaceAll("\\\\","\\\\\\\\");
 							}
-							line = line.replaceAll( ((RegexSearchReplaceJob)(jobs.get(i))).getPattern(), rp );
+							line = line.replaceAll((String)pattern, (String)rp);
+						} else {
+							for ( int i=0; i<jobs.size(); i++ ) {
+								String rp = ((RegexSearchReplaceJob)(jobs.get(i))).getReplacement();
+								if ( ((RegexSearchReplaceJob)(jobs.get(i))).getWinPath() ) {
+									rp = rp.replaceAll("\\\\","\\\\\\\\");
+								}
+								line = line.replaceAll( ((RegexSearchReplaceJob)(jobs.get(i))).getPattern(), rp );
+							}
 						}
-					}
-
-					if ( !oldLine.equals( line ) ) {
-						noReplaces++;
+
+						if ( !oldLine.equals( line ) ) {
+							noReplaces++;
+						}
 					}
 
@@ -210,4 +210,5 @@
 					}
 				}
+				lineNumber++;
 			}
 			
@@ -269,4 +270,32 @@
 	}
 
+	public void setLines(String lines) {
+		//lines should be in the form "2" or "2-5"
+
+		//trim
+		lines.replaceAll("\\s","");
+
+		if ( lines == "" ) {
+			throw new BuildException( "Error - no line number(s) given in lines attribute!! " );
+		}
+
+		//split into parts
+		String[] parts = lines.split("-",2);
+
+		try {
+			if ( parts.length == 1 ) {
+				this.fromLine = Integer.parseInt( parts[0] );
+				this.toLine = this.fromLine + 1;
+			} else {
+				if ( !parts[0].equals("") ) this.fromLine = Integer.parseInt( parts[0] );
+				if ( !parts[1].equals("") ) this.toLine = Integer.parseInt( parts[1] );
+			}
+		} catch( NumberFormatException nfe ) {
+			throw new BuildException( "Error - invalid line numbers given in lines attribute!! '" + parts[0] + "' - '" + parts[1] + "'" );
+		}
+
+	}
+
+
 	public void setPattern(String pattern) {
 		this.pattern = pattern;
