Skip to main content
Participant
Aug 17, 2021 8:08 AM UTC
Answered

Splitting a multiline text field by '\n' is giving me a terribly hard time

I am trying to take the contents of a multi-line text field and split them into an array by the newline escape character but its not working at all.

For reference im trying to make it so that my boss can edit the staff members on a staffing form (as people are hired) by editing the text field, they would then be included in drop down menus.

 

var dropdownexample = this.getField("dropdownmenu")
var stafflist = this.getField("stafflist")
var arr = stafflist.value.split(/\n/);
dropdownexample.setItems(arr);

 

I am just confused why its not picking up the newline character... Im more accustomed to python where this isn't usually a problem. I would greatly appreciate any help y'all have to offer. Thanks!

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Aug 17, 2021 8:15 AM UTC

Probably because the line-break character in multiline fields is "\r", not "\n"...

2 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Aug 17, 2021 8:15 AM UTC

Probably because the line-break character in multiline fields is "\r", not "\n"...

Translate
Participant
Aug 18, 2021 2:23 AM UTC

ah yes this worked!

Translate