SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Aug 2009
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Convert one text structure into another

    Hi,

    I'm trying to convert this text structure:

    PHP Code:
    COLA        COLB     COLC     COLD  
    01.00000 02.00000 03.00000 04.00000  
    05.00000 06.00000 07.00000 08.00000  
    09.00000 10.00000 11.00000 12.00000  
    13.00000 14.00000 15.00000 16.00000 
    into this text structure:

    PHP Code:
    "comp" 4  
    01.00000 
    ;COLA  
    02.00000 
    ;COLB  
    03.00000 
    ;COLC  
    04.00000 
    ;COLD  
    "comp" 4  
    05.00000 
    ;COLA  
    06.00000 
    ;COLB  
    07.00000 
    ;COLC  
    08.00000 
    ;COLD  
    "comp" 4  
    09.00000 
    ;COLA  
    10.00000 
    ;COLB  
    11.00000 
    ;COLC  
    12.00000 
    ;COLD  
    "comp" 4  
    13.00000 
    ;COLA  
    14.00000 
    ;COLB  
    15.00000 
    ;COLC  
    16.00000 
    ;COLD 
    As you can see above (second box), ("comp" 4) line must be added above every group.
    How to do that?

    Thanks in advance,
    minopharma

  2. #2
    Community Advisor silver trophy

    Join Date
    Nov 2006
    Location
    UK
    Posts
    2,559
    Mentioned
    40 Post(s)
    Tagged
    1 Thread(s)
    AS2
    Use String.split and Array.join to replace newlines and spaces

    AS3
    Use String.replace / RegExp class.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •