I am working on a Single Page Application in AngularJS.
There is a Text Area where users can paste some rows from excel. All rows will have same number of columns. I need to process this pasted data and convert it into an javascript array. This is not a problem as I can split the string by \r\n or \n or \r and the fields by \t.
The problem arises if a new line character exists in one of the columns. But in that case, the column is enclosed by quotation marks (").
I understand that regex can be helpful here. However, I am struggling to construct a regex to ignore the new line characters with quotation marks.
//PastedItemData will have the following data
1PS133-0FGD61**\t**"Text with**\r\n**multiple**\r\n**lines"**\t**1**\t**5932.2**\r\n**2PS133-0FGD61**\t**"Simple text with no new lines"**\t**2**\t**1234.5
var PastedItemDataArray = PastedItemData.split("\r\n"); ///use regex here?
I am sure someone else might have faced a similar issue of ignoring new lines in data. Perhaps there might be a different way than using regex. Has any one any ideas?
Thanks.