[Swift-user] regexp problem

Michael Wilde wilde at mcs.anl.gov
Fri Jan 22 12:40:16 CST 2010


You need to specify a string pattern which has at least one matching 
"parenthesized group", as below.

- Mike

--

$ cat strcut.swift

string output0 = "/home/wilde/bigdata/data/modis/output/mydir/my.file";

string pattern = "/home/wilde/bigdata/data/modis/output/(.*)";

string cutresult = @strcut(output0,pattern);

trace("output0",output0);
trace("cutresult",cutresult);login2$


$ swift strcut.swift

Swift svn swift-r3202 cog-r2683

RunID: 20100122-1236-euf2lr6b

Progress:

SwiftScript trace: output0, 
/home/wilde/bigdata/data/modis/output/mydir/my.file

SwiftScript trace: cutresult, mydir/my.file



On 1/22/10 9:59 AM, Antonius Sardjito wrote:
> Hi Dr. Wilde, 
> 
> I am able to readData from the input now, into an array of string.  I am 
> currently trying to use the strcut and strcat to cut the ".tif" and 
> replace it with "Colored.tif"
> 
> I tried to do something like this: 
> 
> string cutresult = 
> @strcut(output[0],"/home/wilde/bigdata/data/modis/output/");
> #outfile = eccho(output[0]);
> trace(output[0]);
> 
> 
> and the error is :
> *
> RunID: 20100122-0951-345qqi15
> Progress:
> SwiftScript trace: /home/wilde/bigdata/data/modis/output/h11v05.tif
> Execution failed:
>         java.lang.IndexOutOfBoundsException: No group 1
> 
>  
> I don't understand why I got the error IndexOutOfBounds, I have checked 
> the string using a procedure that echo the string to a file, and as you 
> can see from above I also checked it with trace(output[0]) which 
> produces a valid value. 
> 
> 
> -Antonius
> 
> 
> ps. 
> 
> This is the whole test file named mini.swift 
> 
> type file;
> file input <"input_for_mini_test.txt">;
> string output[] = readData(input);
> file outfile <"output_for_mini_test.txt">;
> string color = "Colored.tif";
> 
> app (file out) eccho (string inputStr)
> {
>         echo inputStr stdout=@out;
> }
> 
> outfile = eccho(output[0]);
> string cutresult = 
> @strcut(output[0],"/home/wilde/bigdata/data/modis/output/");
> trace(output[0]);
> 
> --EOF--
> 
> *
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Swift-user mailing list
> Swift-user at ci.uchicago.edu
> http://mail.ci.uchicago.edu/mailman/listinfo/swift-user



More information about the Swift-user mailing list