Hi Steve
If you use \n then that is trying to match a non-printable character i.e.
linefeed. The \\n will match the text '\n'.
Example matching linefeed:
> myString := 'one{1}{1}two{1}{1}' format: {String lf}.
> re := '\n' asRegex.
> myString splitOn: re.
Answers a collection of 5 elements.
I am answering my own question because I found the solution for it.
This is the code that didn't work:
> myString := 'one\n\ntwo\n\n'.
> re := '\n\n' asRegex.
> myString splitOn: re.
The reason it didn't work was because you apparently have to escape the
newlines pattern in the regex line. So t
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