Jan. 14, 2019
5:06 p.m.
I am trying to split a string in pharo using a regular expression. A simple example that works: myString := 'one\n\ntwo\n\n'. myString splitOn: '\n\n'. A simple example that does not work: myString := 'one\n\ntwo\n\n'. re := '\n\n' asRegex. myString splitOn: re. The result of the above is I get the regular old string back ('one\n\ntwo\n\n'). I went through the source code and it should be able to handle a regex object:
"splitter - can be a subsequence, a Block or a Regex (String receiver only). Any other object used as a splitter is treated as an Array containing that object."
I am baffled as to why it's not working. is there something simple I am missing? - Steve