grantwood Posted February 6, 2008 Posted February 6, 2008 Hello, I'm using your ScriptMaster plugin (1.6.3), and I have a Java/Groovy problem that I cannot resolve, despite researching it online. Suppose I have the following code: fruits = apple~orange~banana~~~; fruitsArray = fruits.split("~"); Apparently, Java discards the trailing empty strings, which means referencing fruitsArray[4] produces an error (which often causes FileMaker to hang), so how I can preserve the trailing empty strings? Regards, Sean Mills
Jesse Barnum Posted February 8, 2008 Posted February 8, 2008 Sean, use the version of split that takes two args, and pass in a -1 as the second param. See the documentation here: String.split(String regex,int limit) This will return an arry of 6 objects in your example, instead of 3.
grantwood Posted February 10, 2008 Author Posted February 10, 2008 Jesse, thanks so much. That worked! You know, I actually did look at the other version of String.Split, but I simply entered a large number. Didn't know about the -1 parameter. Sean
Recommended Posts
This topic is 6142 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now