Multi-line string - Array?

I was wondering if someone could tell me how to take a multi-line
string and dump it into an array. I'm assuming that I use the 'Pick
Line' function in a while loop? What do I check for to terminate the
loop?
Thanks...
-- N

"kevin" wrote in message news:...
> In article <[email protected]>, "Natalia"
> wrote:
>
> > I was wondering if someone could tell me how to take a multi-line string
> > and dump it into an array. I'm assuming that I use the 'Pick Line'
> > function in a while loop? What do I check for to terminate the loop?
> >
> > Thanks...
> >
> > -- N
>
> Natalia,
>
> Use the 'Spreadsheet String to Array' vi. Use the End of Line delimiter
> (or carriage return, depends on OS). Add a %s to the format string and
> POOF!, an instant text array. No loops required. Oh yeah, you also need
> to add an array string constant to the array type so the output comes ou
t
> as a string type instead of the default double.
>
> You can do it with you present method if you need the loops for other
> stuff. To terminate the loop just look for a -1 in the output of 'Pick
> Line' when searching for you CR or EOL. You just have to remember to dump
> the last value.
>
> good luck,
> - Kevin
Kevin -
Thank you. That did the trick.
-- Natalia

Similar Messages

  • Multi-line String - Match Regular Expression

    I am trying to figure out the format of a regular expression in order to pull select lines out of a multi-line string and populate those lines as individual elements of a string array while using Match Regular Expression. The overall length of the multi-line string can vary as well as the text contained within the string. The string can contain letters, numbers, and special characters. I have attached an example VI. Within the example VI I only want to return the lines beginning with "Device #" into the array. The number of lines beginning with "Device #" can vary but I want to capture them all.
    Or is there a better function to use instead of Match Regular Expression that will give me the desired outcome?  
    Solved!
    Go to Solution.
    Attachments:
    MultiLine Regular Expression.vi ‏22 KB

    aaronb wrote:
    I am trying to figure out the format of a regular expression in order to pull select lines out of a multi-line string and populate those lines as individual elements of a string array while using Match Regular Expression. The overall length of the multi-line string can vary as well as the text contained within the string. The string can contain letters, numbers, and special characters. I have attached an example VI. Within the example VI I only want to return the lines beginning with "Device #" into the array. The number of lines beginning with "Device #" can vary but I want to capture them all.
    Or is there a better function to use instead of Match Regular Expression that will give me the desired outcome?  
    Match Regular Expression works well for this.
    Ben64

  • REGEXP_INSTR on a multi line string

    Hello ,
    I am trying to search through a string that is stored with multi line and trying to find the first occurrence of a character.
    For example : The string is -
    "This is a sample
    text to test
    from [first string] to [second string] "
    When i try to search for the first occurrence of "[" and "]" regular instr function is returning the complete string
    This is the query i used:
    The above string is stored in a varchar2 column named - comments
    select substr(comments,instr(comments,'['),instr(comments,']')) from my_table
    This above query returns : [first string] to [second string]
    i assume instr returns the first occurence of a letter in the given string. i was looking for [first string] but it returns me both. Can this be replaced with regexp_instr function?.
    Any help on this would be much appreciated.
    Thanks

    user619203 wrote:
    Hello ,
    I am trying to search through a string that is stored with multi line and trying to find the first occurrence of a character.
    For example : The string is -
    "This is a sample
    text to test
    from [first string] to [second string] "
    When i try to search for the first occurrence of "[" and "]" regular instr function is returning the complete string
    This is the query i used:
    The above string is stored in a varchar2 column named - comments
    select substr(comments,instr(comments,'['),instr(comments,']')) from my_table
    This above query returns : [first string] to [second string]
    i assume instr returns the first occurence of a letter in the given string. i was looking for [first string] but it returns me both. Can this be replaced with regexp_instr function?.
    Any help on this would be much appreciated.
    Thankslike this?
    SQL> ed
    Wrote file afiedt.buf
      1  with tmp as
      2  (
      3  select 'This is a sample
      4  text to test
      5  from [first string] to [second string]' txt from dual)
      6  select substr(txt, instr(txt, '['), instr(txt, ']') - instr(txt, '[') + 1)
      7* from   tmp
    SQL> /
    SUBSTR(TXT,INS
    [first string]Also questions of these types are better asked in {forum:id=75} forum.

  • JTable -showing column headers and displaying multi-line strings

    Hi,
    This is two questions really.
    #1 - Does anyone know why my column headers aren't showing in my jtable using the model below?
    #2 - Does anyone know how I can display, mulitple line strings in a jtable? Currently my newline character ('\n') is just being displayed as a character.
    any help very much appreciated,
    Tom
    private class TaskHistoryTableModel extends AbstractTableModel {
    private List taskHistory = new ArrayList();
    public Object getValueAt(int row, int col) {
    if (col == 0) {
    return ((TaskHistoryItem) taskHistory.get(row)).getText();
    } else {
    return ((TaskHistoryItem) taskHistory.get(row)).getDate().getTime();
    public int getRowCount() {
    return taskHistory == null ? 0 : taskHistory.size();
    public int getColumnCount() {
    return 2;
    /** Getter for property taskHistory.
    * @return Value of property taskHistory.
    public List getTaskHistory() {
    return taskHistory;
    /** Setter for property taskHistory.
    * @param taskHistory New value of property taskHistory.
    public void setTaskHistory(List taskHistory) {
    this.taskHistory = taskHistory;
    public String getColumnName (int col) {
    return col == 0 ? "Text" : "Entered At";
    public boolean isCellEditable(int row, int col) {
    return false;
    }

    fixed my own problem - make your mulit-line string into html format e.g.
    this string will appear on two lines in a jtable
    "<html><p>A much more interesting entry</p> <p>on multiple lines</p></html>"

  • Additional results doesn't work with multi-line string dat

    I observed an erratic behavior with "Additional Results" in TestStand 2010. The problem statement is as follows:
    1. I have a variable "Locals.FirstName"
    2. I have another variable "Locals.LastName"
    3. Concatenate these two strings with a line feed or a new line character (Locals.FirstName+"\n"+Locals.LastName) and display it in a XML report. 
    Approach:
    1. Using "Statement Expression" I concatenate two strings and print the result using "Additional Results"
    2. For verification I display it using "Message Popup" step type. The formatting is as desired in "Message Popup". However, the new line characters appear as "Spaces" in XML report.
    Tracing Of this Erratic Behavior:
    1. I passed the concatenated string to LabVIEW VI and passed it to "Step.Result.ReportText" variable to log it in XML report. The same string which didn't appeared properly using “Additional Results"of "Statement Expression” step now appears proper in XML report.
    I have attached the sequence file for reference. Ensure that Report option is set to XML before executing this sequence.
    Can anyone justify this behavior and suggest the correct approach??
    Thanks !
    Attachments:
    Erratic Behavior Of Additional Results.seq ‏8 KB
    Tracing Of Erratic Behavior.vi ‏9 KB

    Amit -
    Here is a modified version of the TestStand 2010 Horizontal.xsl style sheet that corrects the issue you have mentioned. Note that leading and trailing "\n" characters will still be stripped out, and all "\r" characters will be stripped out.
    Hope this helps.
    Manooch H.
    National Instruments
    Attachments:
    horizontal_modified.zip ‏22 KB

  • Given a multi-line string I want to append a string constant to the beginning of each line.

    Thankyou.

    You could just use "search and replace" with the search string being "\n" (in \codes display) and the replace string as "constant\n". (See attached image).
    If the string you want at the beginning of each line is variable (e.g. line number), you should use e.g. "pick line" or "scan strings for tokens" in a loop, then rebuild the new string.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    AppendConstant.gif ‏9 KB

  • Multi line strings - line continuation chars?

    Hi all,
    I'm not sure if this is a daft question or not...
    I need to put a multiline select statement into a string variable.
    ie I would like to put the sql below into a variable.
    select bla bla bla bla bla
    from bla
    where bla
    strvar := 'select bla bla bla bla bla
    from bla
    where bla';
    Is there a standard line continuation character that I can put at the end of each line to enable me to put the single quote and the beginning of line 1 and the end of line 3? Or do I need to quote each line front and back and cat them together as separate strings?
    rgds
    John

    Hi John,
    See if this can help you
    declare str varchar2(10000);
    begin
    str := 'select bla bla bla bla bla '||chr(10);
    str := str||'from bla '||chr(10);
    str := str||'where bla '||chr(10);
    dbms_output.put_line(str);
    end;
    SQL> /
    the output should be like below :
    select bla bla bla bla bla
    from bla
    where bla
    Anyway new line character is chr(10) for SQL.
    Thanks
    Kailash K Agarwalla,
    Delhi, India.

  • Need help - ResourceBundle - formated string value (and multi-line string)

    Hi
    Can I put a value for key on many rows and formatted??
    Ex.: Into a file properties can I put
    key =
    My
    name
    is
    JTonic
    When I try to get the value for key, I get "". Can I get "My name is JToniC" ???
    Thx in advance.

    http://java.sun.com/j2se/1.4.2/docs/api/java/util/Properties.html#load(java.io.InputStream)
    The logical line holding all the data for a key-element pair may be spread out across several adjacent natural lines by escaping the line terminator sequence with a backslash character, \.

  • How to discover multi-line of String that will come Flex by Java?

    Hi all,
    I am programming a little application by using Java and Flex.
    One of the functions that Flex contains will have the responsibility to
    send the TextArea value to Java as parameter.
    But that value could contain multi-lines string. Java recieved successfully but the problem that Java read it as single line.
    so, how can I fix this problem?

    Hi,
    so, is there any solution available right now for my problem.
    A text that will come from TextArea that could contains multi-lines
    will be sent to Java as paramenter.
    How can I distinguish the multi-lines onec I deal with it as String?

  • How to determine the length of a line of text in a multi line text control

    I am working on a simple widget to compare two snippets of text.  The string controls are side by side with a colum of square bools in between
    the two string controls.
    The Bools line up with the lines of text in each string control.  The Bools are used as a quick indicator that at that line point there is a difference
    between the two string controls.
     There is a slider that allows the user to scroll up and down,  the slider scrolls both string controls simutaneously.
    As the string controls are scrolled I will be comparing the left and right lines of text and reflecting the match status in the Bool Colum.
    The reason I need to know the length of the line of text is so each line can be compared against one another.  It is not as simple as counting the
    col width of the string control and parsing the text because if there is a line return the text will word wrap before before it extends all the way accross the string control, which will cause parsing discrepencies.
    Any suggestions on obtaining the multi line string control text character length would be much appreciated.
    Best Regards
    Tim C. 
    1:30 Seconds ARRRGHHH!!!! I want my popcorn NOW! Isn't there anything faster than a microwave!

    Front panel of widget....
    1:30 Seconds ARRRGHHH!!!! I want my popcorn NOW! Isn't there anything faster than a microwave!
    Attachments:
    One.vi ‏27 KB

  • Multi line pattern search with like

    Hi All,
    I am using oracle 9i. I want to search for multi - line pattern.
    for e.g.
    update tablename
    set columnname .
    I used select * from user_source where text like '%update tablename%set columnname%' but this only seem to work if update tablename set columnname is in the same line .
    Thanks.

    Well, no wonder it does not work. USER_SOURCE stores one line of text per row, so column text by definition can not contain multi-line strings . One solution could be analytic function LEAD:
    SQL> create or replace
      2    procedure p1
      3      is
      4      begin
      5          update emp
      6             set ename = ename;
      7  end;
      8  /
    Procedure created.
    SQL> select  distinct name
      2    from  (
      3           select  s.*,
      4                   lead(text) over(partition by name order by line) next_text
      5             from  user_source s
      6          )
      7    where text like '%update emp%'
      8      and next_text like '%set ename%'
      9  /
    NAME
    P1
    SQL> SY.

  • Multi-dimensioned global arrays

    I'm using a couple of global multi-dimensioned string arrays (they're used in multiple functions throughout the program) and I don't know the boundaries of either dimension until run-time.
    It works fine to use the "new" on a single-dimensioned array, but I'm getting a compiler error when I try:
    std::string* dta = new std::string[x][y];
    Any ideas what the problem is?

    It works fine to use the "new" on a single-dimensioned array, but I'm getting a compiler error when I try:
    std::string* dta = new std::string[x][y];
    How do I declare a 2d array in C++ using new?
    http://stackoverflow.com/questions/936687/how-do-i-declare-a-2d-array-in-c-using-new
    - Wayne

  • Saving an array of multi-line text cells in a format that can be read in later

    I can create an array of multi-line text entries that my program can then pick cells and compile them into a list of text.
    I would like to be able to Save the array as a file, then change my program to read in the file.
    If I use the Save Spreadsheet file vi, the data is corrupted by the carriage returns within the cells and the data read in is messed up.
    Can someone recommend a way to save the array that preserves the carriage returns?

    As far as I know, this cannot be done automatically with the basic VIs from the palletes.  I would convert the [LF] into another group of characters (likely "\n") and then save the text array to a CSV file.  Don't forget to escape any good "\" string with an extra "\.  Regular expressions would work really well:
    Just make sure you parse your entire array of strings with this.
    Olivier
    Attachments:
    SaveToCSV_WithMultiLine.vi ‏9 KB

  • String Array declaration with multiple lines

    I have an array declaration with several indexes where it covers multiple lines.
    Please advise if this is the best way to declare an array declaration with multiple lines:
    String cityString = "San Diego, Oakland, London, New York, Dublin," +
    "Dallas, Milan";
    String city[] = cityString.split(",");

    String[] city = {"San Diego", "Oakland", "London",
    "New York", "Dublin", "Dallas", "Toronto"};You can use indentation and line breaks as you like, as usual in Java.

  • Remove null values from string array

    Hi ,
    I have a string array in a jsp page which I save some values inside. After I store the values I want to print only those who are not null. How can I do this? Is there a way to delete the null values?

    Thank you but because I am new in programming what do you mean to use continue. Can you explain it a little bit further?<%
    //go through the array to check all the values
    for(int i=0; i<array.length();i++) {
    //If array is null, nothing happen
    if(array==null){
    //leave here blank; instead use continue like:
    //this will skip the statements next to it, and increments the value of i in for loop and continues to execute the body of for loop.
    //The same will be repeated till the last iteration.
    continue;
    //If array not null, then print value in a new line
    else{
    out.print(array+"<br>"); //don't change the logic here
    %>

Maybe you are looking for