Regex Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreRegex Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 13th, 2013, 03:20 AM
JvM JvM is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 2 JvM User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 7 sec
Reputation Power: 0
Paste from excel

Hi

I am trying to provide an easy import from excel feature to the user. They can copy paste some values from the excel template to the webinterface. However when excel has a multiline cell (I mean a cell with a break (or multiple) in it, not merged cells).

Example:
Code:
Col1            Col2
Test1           Res1
Test2           Res2a
                   Res2b
Test3           Res3
Test4           Res4a
                   Res4b
                   Res4c

(The multiline can be an unknown amount of lines)


I want to import these and add them to a form with a textarea per field so 2 fields per row.

Now i can do this for the singleline cells, however how can I use this for the multiline?
I am thinking for something in the split, however I can not figure out what. I tried some regexpressions, but I', not so well known with these.

jQuery code used:
Code:
var data = $("#import_text").val();                    
 var arr = data.split( /[\r\n]/g );
      $.each(arr, function(i){
            row = arr[i].split( /\t/ );
            col1 = $.trim(row[0]);
            col2 = $.trim(row[1]);
            //Set values and such
       }
});


When copying from excel the export is
Test1 (tab) Res1 (break)
Test2 (tab) "Res2a (break)
Res2b"(break)
Test3 (tab) Res3 (break)
Test4 (tab) "Res4a (break)
Res4b (break)
Res4c"(break)



I think I will need a regex that can convert the breaks within the quoted text, however I don't know how. Can you help out?

Reply With Quote
  #2  
Old January 13th, 2013, 08:22 AM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Click here for more information.
 
Join Date: Dec 2004
Posts: 7,931 E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 90th Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 7 h 43 m 47 sec
Reputation Power: 6991
What value do you get in your application if the Excel field contains a literal "?
__________________
PHP FAQ
How to program a basic, secure login system using PHP

Quote:
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

Reply With Quote
  #3  
Old January 13th, 2013, 09:27 AM
JvM JvM is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 2 JvM User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 7 sec
Reputation Power: 0
That indeed will screw things up, however if I recall correctly only singlequotes are used

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreRegex Programming > Paste from excel

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap