Home » Modeling » Epsilon » Behaviour of String.split()
Behaviour of String.split() [message #468410] |
Wed, 05 August 2009 13:15 |
Eclipse User |
|
|
|
Originally posted by: c.k.holmes.lboro.ac.uk
Behaviour of the operation split on the class String is curious. The
following output is generated from a simple model transformation:
This input (within my ETL file):
'1234.5678'.println();
'1234.5678'.split('.').println();
'1234-5678'.println();
'1234-5678'.split('-').println();
Provides this output (in the console window):
main:
[epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl] Running
ETL file
[epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl] 1234.5678
[epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl] Sequence {}
[epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl] 1234-5678
[epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl] Sequence
{1234, 5678}
[epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
Completed ETL file
BUILD SUCCESSFUL
There appears to be something odd with the behaviour of the split()
operation when the string delimiter is the point character '.', should I
be calling this operation differently?
Best Wishes
Chris
|
|
| |
Re: Behaviour of String.split() [message #468461 is a reply to message #468452] |
Wed, 05 August 2009 15:31 |
Louis Rose Messages: 440 Registered: July 2009 Location: York, United Kingdom |
Senior Member |
|
|
Hi Chris,
As Steffen mentions, the argument to split is a regular expression, in
which the . has special meaning.
split('\\.') is the correct way to phrase this query, as backslashes
must be escaped in EOL strings.
Cheers,
Louis.
Steffen Zschaler wrote:
> Hi Chris,
>
> Keep in mind that the argument to split is a regular expression. Thus,
> split('.') means split at any character, which naturally gives you the
> empty sequence. You may want to try split ('\.') instead (not tested)
>
> Steffen
>
> Chris Holmes wrote:
>> Behaviour of the operation split on the class String is curious. The
>> following output is generated from a simple model transformation:
>>
>> This input (within my ETL file):
>> '1234.5678'.println();
>> '1234.5678'.split('.').println();
>> '1234-5678'.println();
>> '1234-5678'.split('-').println();
>>
>> Provides this output (in the console window):
>> main:
>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>> Running ETL file
>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl] 1234.5678
>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>> Sequence {}
>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl] 1234-5678
>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>> Sequence {1234, 5678}
>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>> Completed ETL file
>> BUILD SUCCESSFUL
>>
>> There appears to be something odd with the behaviour of the split()
>> operation when the string delimiter is the point character '.', should
>> I be calling this operation differently?
>>
>> Best Wishes
>> Chris
|
|
|
Re: Behaviour of String.split() [message #468477 is a reply to message #468461] |
Wed, 05 August 2009 15:55 |
Eclipse User |
|
|
|
Originally posted by: c.k.holmes.lboro.ac.uk
Louis/Steffen,
Thanks for your help, setting the delimiter to '\\.' corrects the
problem. Is there a definitive description of such operations? I'm
currently using 'The Epsilon Book', this seems to neglect to mention
that the delimiter is an RE.
Best Wishes
Chris
Louis Rose wrote:
> Hi Chris,
>
> As Steffen mentions, the argument to split is a regular expression, in
> which the . has special meaning.
>
> split('\\.') is the correct way to phrase this query, as backslashes
> must be escaped in EOL strings.
>
> Cheers,
> Louis.
>
> Steffen Zschaler wrote:
>> Hi Chris,
>>
>> Keep in mind that the argument to split is a regular expression. Thus,
>> split('.') means split at any character, which naturally gives you the
>> empty sequence. You may want to try split ('\.') instead (not tested)
>>
>> Steffen
>>
>> Chris Holmes wrote:
>>> Behaviour of the operation split on the class String is curious. The
>>> following output is generated from a simple model transformation:
>>>
>>> This input (within my ETL file):
>>> '1234.5678'.println();
>>> '1234.5678'.split('.').println();
>>> '1234-5678'.println();
>>> '1234-5678'.split('-').println();
>>>
>>> Provides this output (in the console window):
>>> main:
>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>> Running ETL file
>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>> 1234.5678
>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>> Sequence {}
>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>> 1234-5678
>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>> Sequence {1234, 5678}
>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>> Completed ETL file
>>> BUILD SUCCESSFUL
>>>
>>> There appears to be something odd with the behaviour of the split()
>>> operation when the string delimiter is the point character '.',
>>> should I be calling this operation differently?
>>>
>>> Best Wishes
>>> Chris
|
|
|
Re: Behaviour of String.split() [message #471802 is a reply to message #468477] |
Wed, 05 August 2009 18:57 |
Louis Rose Messages: 440 Registered: July 2009 Location: York, United Kingdom |
Senior Member |
|
|
Hi Chris,
I think that the Epsilon Book is the best reference, though Dimitrios
may have a view on this when he returns from vacation.
I've corrected the description of split in the book, which can be found
here:
http://dev.eclipse.org/svnroot/modeling/org.eclipse.gmt.epsi lon/trunk/doc/org.eclipse.epsilon.book/EpsilonBook.pdf
Apologies for the inconsistency.
Best,
Louis.
Chris Holmes wrote:
> Louis/Steffen,
> Thanks for your help, setting the delimiter to '\\.' corrects the
> problem. Is there a definitive description of such operations? I'm
> currently using 'The Epsilon Book', this seems to neglect to mention
> that the delimiter is an RE.
>
> Best Wishes
> Chris
>
> Louis Rose wrote:
>> Hi Chris,
>>
>> As Steffen mentions, the argument to split is a regular expression, in
>> which the . has special meaning.
>>
>> split('\\.') is the correct way to phrase this query, as backslashes
>> must be escaped in EOL strings.
>>
>> Cheers,
>> Louis.
>>
>> Steffen Zschaler wrote:
>>> Hi Chris,
>>>
>>> Keep in mind that the argument to split is a regular expression.
>>> Thus, split('.') means split at any character, which naturally gives
>>> you the empty sequence. You may want to try split ('\.') instead (not
>>> tested)
>>>
>>> Steffen
>>>
>>> Chris Holmes wrote:
>>>> Behaviour of the operation split on the class String is curious. The
>>>> following output is generated from a simple model transformation:
>>>>
>>>> This input (within my ETL file):
>>>> '1234.5678'.println();
>>>> '1234.5678'.split('.').println();
>>>> '1234-5678'.println();
>>>> '1234-5678'.split('-').println();
>>>>
>>>> Provides this output (in the console window):
>>>> main:
>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>> Running ETL file
>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>> 1234.5678
>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>> Sequence {}
>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>> 1234-5678
>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>> Sequence {1234, 5678}
>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>> Completed ETL file
>>>> BUILD SUCCESSFUL
>>>>
>>>> There appears to be something odd with the behaviour of the split()
>>>> operation when the string delimiter is the point character '.',
>>>> should I be calling this operation differently?
>>>>
>>>> Best Wishes
>>>> Chris
|
|
|
Re: Behaviour of String.split() [message #478258 is a reply to message #471802] |
Thu, 06 August 2009 09:05 |
Steffen Zschaler Messages: 266 Registered: July 2009 |
Senior Member |
|
|
Hi Chris,
Also, of course, keep in mind that String is just the standard
java.lang.String, so the definite reference (with the exception of the
additional need to escape backslashes) is the standard JAVA API reference.
Steffen
Louis Rose wrote:
> Hi Chris,
>
> I think that the Epsilon Book is the best reference, though Dimitrios
> may have a view on this when he returns from vacation.
>
> I've corrected the description of split in the book, which can be
> found here:
> http://dev.eclipse.org/svnroot/modeling/org.eclipse.gmt.epsi lon/trunk/doc/org.eclipse.epsilon.book/EpsilonBook.pdf
>
>
> Apologies for the inconsistency.
>
> Best,
> Louis.
>
> Chris Holmes wrote:
>> Louis/Steffen,
>> Thanks for your help, setting the delimiter to '\\.' corrects the
>> problem. Is there a definitive description of such operations? I'm
>> currently using 'The Epsilon Book', this seems to neglect to mention
>> that the delimiter is an RE.
>>
>> Best Wishes
>> Chris
>>
>> Louis Rose wrote:
>>> Hi Chris,
>>>
>>> As Steffen mentions, the argument to split is a regular expression,
>>> in which the . has special meaning.
>>>
>>> split('\\.') is the correct way to phrase this query, as backslashes
>>> must be escaped in EOL strings.
>>>
>>> Cheers,
>>> Louis.
>>>
>>> Steffen Zschaler wrote:
>>>> Hi Chris,
>>>>
>>>> Keep in mind that the argument to split is a regular expression.
>>>> Thus, split('.') means split at any character, which naturally
>>>> gives you the empty sequence. You may want to try split ('\.')
>>>> instead (not tested)
>>>>
>>>> Steffen
>>>>
>>>> Chris Holmes wrote:
>>>>> Behaviour of the operation split on the class String is curious.
>>>>> The following output is generated from a simple model transformation:
>>>>>
>>>>> This input (within my ETL file):
>>>>> '1234.5678'.println();
>>>>> '1234.5678'.split('.').println();
>>>>> '1234-5678'.println();
>>>>> '1234-5678'.split('-').println();
>>>>>
>>>>> Provides this output (in the console window):
>>>>> main:
>>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>>> Running ETL file
>>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>>> 1234.5678
>>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>>> Sequence {}
>>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>>> 1234-5678
>>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>>> Sequence {1234, 5678}
>>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>>> Completed ETL file
>>>>> BUILD SUCCESSFUL
>>>>>
>>>>> There appears to be something odd with the behaviour of the
>>>>> split() operation when the string delimiter is the point character
>>>>> '.', should I be calling this operation differently?
>>>>>
>>>>> Best Wishes
>>>>> Chris
|
|
| |
Re: Behaviour of String.split() [message #572361 is a reply to message #468452] |
Wed, 05 August 2009 15:31 |
Louis Rose Messages: 440 Registered: July 2009 Location: York, United Kingdom |
Senior Member |
|
|
Hi Chris,
As Steffen mentions, the argument to split is a regular expression, in
which the . has special meaning.
split('\\.') is the correct way to phrase this query, as backslashes
must be escaped in EOL strings.
Cheers,
Louis.
Steffen Zschaler wrote:
> Hi Chris,
>
> Keep in mind that the argument to split is a regular expression. Thus,
> split('.') means split at any character, which naturally gives you the
> empty sequence. You may want to try split ('\.') instead (not tested)
>
> Steffen
>
> Chris Holmes wrote:
>> Behaviour of the operation split on the class String is curious. The
>> following output is generated from a simple model transformation:
>>
>> This input (within my ETL file):
>> '1234.5678'.println();
>> '1234.5678'.split('.').println();
>> '1234-5678'.println();
>> '1234-5678'.split('-').println();
>>
>> Provides this output (in the console window):
>> main:
>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>> Running ETL file
>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl] 1234.5678
>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>> Sequence {}
>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl] 1234-5678
>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>> Sequence {1234, 5678}
>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>> Completed ETL file
>> BUILD SUCCESSFUL
>>
>> There appears to be something odd with the behaviour of the split()
>> operation when the string delimiter is the point character '.', should
>> I be calling this operation differently?
>>
>> Best Wishes
>> Chris
|
|
|
Re: Behaviour of String.split() [message #572422 is a reply to message #468461] |
Wed, 05 August 2009 15:55 |
Eclipse User |
|
|
|
Originally posted by: c.k.holmes.lboro.ac.uk
Louis/Steffen,
Thanks for your help, setting the delimiter to '\\.' corrects the
problem. Is there a definitive description of such operations? I'm
currently using 'The Epsilon Book', this seems to neglect to mention
that the delimiter is an RE.
Best Wishes
Chris
Louis Rose wrote:
> Hi Chris,
>
> As Steffen mentions, the argument to split is a regular expression, in
> which the . has special meaning.
>
> split('\\.') is the correct way to phrase this query, as backslashes
> must be escaped in EOL strings.
>
> Cheers,
> Louis.
>
> Steffen Zschaler wrote:
>> Hi Chris,
>>
>> Keep in mind that the argument to split is a regular expression. Thus,
>> split('.') means split at any character, which naturally gives you the
>> empty sequence. You may want to try split ('\.') instead (not tested)
>>
>> Steffen
>>
>> Chris Holmes wrote:
>>> Behaviour of the operation split on the class String is curious. The
>>> following output is generated from a simple model transformation:
>>>
>>> This input (within my ETL file):
>>> '1234.5678'.println();
>>> '1234.5678'.split('.').println();
>>> '1234-5678'.println();
>>> '1234-5678'.split('-').println();
>>>
>>> Provides this output (in the console window):
>>> main:
>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>> Running ETL file
>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>> 1234.5678
>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>> Sequence {}
>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>> 1234-5678
>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>> Sequence {1234, 5678}
>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>> Completed ETL file
>>> BUILD SUCCESSFUL
>>>
>>> There appears to be something odd with the behaviour of the split()
>>> operation when the string delimiter is the point character '.',
>>> should I be calling this operation differently?
>>>
>>> Best Wishes
>>> Chris
|
|
|
Re: Behaviour of String.split() [message #572497 is a reply to message #468477] |
Wed, 05 August 2009 18:57 |
Louis Rose Messages: 440 Registered: July 2009 Location: York, United Kingdom |
Senior Member |
|
|
Hi Chris,
I think that the Epsilon Book is the best reference, though Dimitrios
may have a view on this when he returns from vacation.
I've corrected the description of split in the book, which can be found
here:
http://dev.eclipse.org/svnroot/modeling/org.eclipse.gmt.epsi lon/trunk/doc/org.eclipse.epsilon.book/EpsilonBook.pdf
Apologies for the inconsistency.
Best,
Louis.
Chris Holmes wrote:
> Louis/Steffen,
> Thanks for your help, setting the delimiter to '\\.' corrects the
> problem. Is there a definitive description of such operations? I'm
> currently using 'The Epsilon Book', this seems to neglect to mention
> that the delimiter is an RE.
>
> Best Wishes
> Chris
>
> Louis Rose wrote:
>> Hi Chris,
>>
>> As Steffen mentions, the argument to split is a regular expression, in
>> which the . has special meaning.
>>
>> split('\\.') is the correct way to phrase this query, as backslashes
>> must be escaped in EOL strings.
>>
>> Cheers,
>> Louis.
>>
>> Steffen Zschaler wrote:
>>> Hi Chris,
>>>
>>> Keep in mind that the argument to split is a regular expression.
>>> Thus, split('.') means split at any character, which naturally gives
>>> you the empty sequence. You may want to try split ('\.') instead (not
>>> tested)
>>>
>>> Steffen
>>>
>>> Chris Holmes wrote:
>>>> Behaviour of the operation split on the class String is curious. The
>>>> following output is generated from a simple model transformation:
>>>>
>>>> This input (within my ETL file):
>>>> '1234.5678'.println();
>>>> '1234.5678'.split('.').println();
>>>> '1234-5678'.println();
>>>> '1234-5678'.split('-').println();
>>>>
>>>> Provides this output (in the console window):
>>>> main:
>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>> Running ETL file
>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>> 1234.5678
>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>> Sequence {}
>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>> 1234-5678
>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>> Sequence {1234, 5678}
>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>> Completed ETL file
>>>> BUILD SUCCESSFUL
>>>>
>>>> There appears to be something odd with the behaviour of the split()
>>>> operation when the string delimiter is the point character '.',
>>>> should I be calling this operation differently?
>>>>
>>>> Best Wishes
>>>> Chris
|
|
|
Re: Behaviour of String.split() [message #572525 is a reply to message #471802] |
Thu, 06 August 2009 09:05 |
Steffen Zschaler Messages: 266 Registered: July 2009 |
Senior Member |
|
|
Hi Chris,
Also, of course, keep in mind that String is just the standard
java.lang.String, so the definite reference (with the exception of the
additional need to escape backslashes) is the standard JAVA API reference.
Steffen
Louis Rose wrote:
> Hi Chris,
>
> I think that the Epsilon Book is the best reference, though Dimitrios
> may have a view on this when he returns from vacation.
>
> I've corrected the description of split in the book, which can be
> found here:
> http://dev.eclipse.org/svnroot/modeling/org.eclipse.gmt.epsi lon/trunk/doc/org.eclipse.epsilon.book/EpsilonBook.pdf
>
>
> Apologies for the inconsistency.
>
> Best,
> Louis.
>
> Chris Holmes wrote:
>> Louis/Steffen,
>> Thanks for your help, setting the delimiter to '\\.' corrects the
>> problem. Is there a definitive description of such operations? I'm
>> currently using 'The Epsilon Book', this seems to neglect to mention
>> that the delimiter is an RE.
>>
>> Best Wishes
>> Chris
>>
>> Louis Rose wrote:
>>> Hi Chris,
>>>
>>> As Steffen mentions, the argument to split is a regular expression,
>>> in which the . has special meaning.
>>>
>>> split('\\.') is the correct way to phrase this query, as backslashes
>>> must be escaped in EOL strings.
>>>
>>> Cheers,
>>> Louis.
>>>
>>> Steffen Zschaler wrote:
>>>> Hi Chris,
>>>>
>>>> Keep in mind that the argument to split is a regular expression.
>>>> Thus, split('.') means split at any character, which naturally
>>>> gives you the empty sequence. You may want to try split ('\.')
>>>> instead (not tested)
>>>>
>>>> Steffen
>>>>
>>>> Chris Holmes wrote:
>>>>> Behaviour of the operation split on the class String is curious.
>>>>> The following output is generated from a simple model transformation:
>>>>>
>>>>> This input (within my ETL file):
>>>>> '1234.5678'.println();
>>>>> '1234.5678'.split('.').println();
>>>>> '1234-5678'.println();
>>>>> '1234-5678'.split('-').println();
>>>>>
>>>>> Provides this output (in the console window):
>>>>> main:
>>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>>> Running ETL file
>>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>>> 1234.5678
>>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>>> Sequence {}
>>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>>> 1234-5678
>>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>>> Sequence {1234, 5678}
>>>>> [epsilon.etl - IndeFile2NetworkInitialisationDataCatalogue.etl]
>>>>> Completed ETL file
>>>>> BUILD SUCCESSFUL
>>>>>
>>>>> There appears to be something odd with the behaviour of the
>>>>> split() operation when the string delimiter is the point character
>>>>> '.', should I be calling this operation differently?
>>>>>
>>>>> Best Wishes
>>>>> Chris
|
|
|
Goto Forum:
Current Time: Wed Sep 25 21:36:24 GMT 2024
Powered by FUDForum. Page generated in 0.04887 seconds
|