This is a single field value and has to be split based on blank lines.


abc street 
city 785263 

lmn street 
city 462738 

I tried AddressList = addresses.split('\n{2}') but dose not work.

  • Use addresses.split('\\s').
    – arut
    Commented Sep 28, 2020 at 4:31
  • @arut blank lines, not just blanks?
    – sfdcfox
    Commented Sep 28, 2020 at 4:37
  • @sfdcfox My bad [+1 to your ans]. I ran only by the title before commenting.
    – arut
    Commented Sep 28, 2020 at 4:44

1 Answer 1


addresses.split('\n{2}') only works if it's actually just newlines (\n). There are three common newline connections, LF (\n), CR (\r), and CRLF (\r\n).

To be compatible with all of these, try:


This has several parts:

(?m) multiline mode enabled
\\s* zero or more whitespace
^ Beginning of a line (multiline mode)
$ End of a line (multiline mode)

So: "In multiline mode, find any spaces followed by any start of line, with any spaces, then an end of line, followed by any more spaces."

Or, you could replace CRLF and Cr to just LF, then your original code should work:

  • addresses.replaceAll('(\\r\\n|\\r)','\n').split('\n{2}') Thanks, it worked.
    – user70573
    Commented Sep 28, 2020 at 9:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .