You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Vinny <xa...@gmail.com> on 2008/06/05 05:07:24 UTC

Re: splitting on a period ? <- please ignore

Sorry,
I sent this to the wrong "user" list.

On Wed, Jun 4, 2008 at 11:06 PM, Vinny <xa...@gmail.com> wrote:
> OK, this one baffles me :)
>
> "file.txt".split(".")  produces an empty array ?
>
>
>
>
>
> testing it on the groovysh, (trying to that more often before posting
> on the list) :
>
>
> groovy:000> mysplit = "file.txt".split(".")
> ===> [Ljava.lang.String;@73b4f342
> groovy:000> mysplit.size()
> ===> 0
> groovy:000> println mysplit
> {}
> ===> null
>
> Thanks in advance.
>
> --
> The future is here. It's just not widely distributed yet.
> -William Gibson
>



-- 
The future is here. It's just not widely distributed yet.
-William Gibson

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: splitting on a period ? <- please ignore

Posted by Holger Stratmann <ap...@finch.de>.
Vinny wrote:
> Sorry,
> I sent this to the wrong "user" list.
Yes you did - and that's why I know a lot of Java and only a little Groovy.
(and cannot see if anybody has answered your question)

Anyway, this should be the same in Java and Groovy: String.split uses a 
REGULAR EXPRESSION to split.
A period (.) is a wildcard for "any character" and therefore regards 
every character as a separator with "nothing in between" :-)

You must escape the period, it should work with split("\\.")

Good luck!
>
> On Wed, Jun 4, 2008 at 11:06 PM, Vinny <xa...@gmail.com> wrote:
>> OK, this one baffles me :)
>>
>> "file.txt".split(".")  produces an empty array ?
>>
>>
>>
>>
>>
>> testing it on the groovysh, (trying to that more often before posting
>> on the list) :
>>
>>
>> groovy:000> mysplit = "file.txt".split(".")
>> ===> [Ljava.lang.String;@73b4f342
>> groovy:000> mysplit.size()
>> ===> 0
>> groovy:000> println mysplit
>> {}
>> ===> null
>>
>> Thanks in advance.
>>
>> --
>> The future is here. It's just not widely distributed yet.
>> -William Gibson
>>
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org