Search and Replace String Function replaces line feeds when I only want spaces replaced?

I need to replace every instance of a space or series of spaces in a multi line string with commas (or tabs) so I can dump it into a spreadsheet.
I am using the regular expresion [\s]+ and it works but it is also replacing the end of lines (\r\n) too.
How can I make it replace the spaces but leave teh end of lines intact?
Solved!
Go to Solution.
Attachments:
replace.vi ‏6 KB

Right click on the search string and change it to '\' Code Display. Enter the space character (\s) correctly - you've got \\s right now.

Similar Messages

  • How to get numeric result from 'search and replace' string function

    hii
    i am using search and replace function to get output.my output is of form ' *X0123.3 ' .here i am replacing the term *X01 with space because i need only 23.3 as a result.but i am unable to get that out in the output indicator.i used lot of functions like string to number and so on but i am getting output as zero .can you please suggest me wt to do.i am attaching a copy of my file.
    Attachments:
    Untitled 1.vi ‏25 KB

    Your problem is the fact that you are converting it to an integer, thus loosing the fractional part. You need to use "Fract/Exp String To Number" instead and create a DBL so yor data is 23.3 instead of 23.
    You also don't need to manipulate the string if the initial part is of constant lenght. Just use the offset input as in the figure below.
    Message Edited by altenbach on 07-31-2006 07:02 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ToDBL.png ‏2 KB

  • Search and replace string function

    Hello, I am using the "search and replace string" function and it does nt seem to work consistently for me.   I am using it in a situation where I am taking an array of strings, converting this into a spreadsheet string then deleting all of the commas.  Has anyone experienced the same behavior? I have searched through other posts and found other simular faults but none of the fixes worked for this. I can post the code it needed.
    Thanks,
    Andrew

    I agree that commas are often not desirable, especially if your software should also work in countries where comma is used as a decimal seperator.
    Where are the commas coming from? Does (1) each element of the original array have one (or more), do you (2) use comma as seperator if you convert it to a spreadhseet string?
    For (1), you might just strip out the comma for each element right in the loop. For case (2) you would simply use a different separator to begin with, of course.
    Btw: you are abusing a WHILE loop as a FOR loop, because you have a fixed number of iterations. Please replace it with a FOR loop. If you use a FOR loop, LabVIEW can manage memory much more efficiently, because it can allocate the entire output array before the loop starts. For While loops, the total number of iterations is not known to the compiler. (Of course a real program would also stop the loop if an error occurs. In this case you would need to stay woth the WHILE loop. )
    Do you have a simple example how the raw array elements look like. How many commas are there?
    LabVIEW Champion . Do more with less code and in less time .

  • Search and replace string formatting

    Hi,
    I am trying to do a search and replace formatting of a string.
    In the example I am looking for string "PASSED" but it must also start with usbflash and some number + PASSED.
    I can't get the format to have a number from 1-99. The number of replacements should add up to 6 in this case. I have tried with \d for any number, and I also tried [1-99].
    Solved!
    Go to Solution.

    Right click on the Search And Replace String function.  There is an option to use Regular Expressions.  Then give this a try.
    EDIT: You will need to set the Replace All input to TRUE.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Match Pattern.png ‏12 KB

  • Search and replace string problems

    Hi to all,
    I have problem with Search and replace string function. It shows me a wrong Value (Number) from 15 to 100 is everything OK (15=0, 30=1, 45=2, 100=3), but after 100 ........
    Take look in VI and if you have any ideas post them please
    THX
    Igor 
    Attachments:
    indexing.vi ‏10 KB

    there will be no 15115 string, but 15 or 115 and 15 is 0, 115 is 4. Anyway, i have changed string input format and now its working THX for your help
    Attachments:
    indexing.vi ‏10 KB

  • Using a variable in a Powershell search and replace string

    Hi
    a couple of days ago I posted a question about doing a search and replace with wildcards
    Search and repalce with Widcards
    I got a swift and very helpful answer but now I need to build on it.
    In a text file I wanted to replace all the text between two defined words.  the script I got was this
    $text = 'Some Server this bit of text varies Language stuff'
    $text -replace '(.*Server) .+? (Language.*)','$1 it will always say this $2'
    It works great but now I want to replace "it will always say this" with a variable and I can't figure out the correct grammar to make this happen.
    Can anyone help??
    Thanks
    Alex

    Here's one way:
    $replace = 'it will aways say this'if ( $text -match '(.*Server) .+? (Language.*)' )
    { "{0} $Replace {1}" -f $matches[1,2] }
    else { $text }
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • Search and replace strings in a file while ignoring substrings

    Hi:
    I have a java program that searches and replaces strings in a file. It makes a new copy of the file, searches for a string in the copy, replaces the string and renames the new copy to the original file, thereafter deleting the copy.
    Now searching for "abcd", for eg works fine, but searching for "Topabcd" and replacing it doesnot work because there is a match for "abcd" in a different search scenario. How can I modify the code such that if "abcd" is already searched and replaced then it should not be searched for again or rather search for "abcd" as entire string and not if its a substring of another string.
    In the below code output, all instances of "abcd" and the ones of "Topabcd" are replaced by ABCDEFG and TopABCDEF respectively, whereas according to the desired output, "abcd" should be replaced by ABCDEFG and "Topabcd" should be replaced by REPLACEMEFIRST.
    try
              String find_productstring = "abcd";
              String replacement_productstring = "ABCDEFG";
              compsXml = new FileReader(compsLoc);
              compsConfigFile = new BufferedReader(compsXml);
              File compsFile =new File("file.xml");
              File compsNewFile =new File("file1.xml");
              BufferedWriter out =new BufferedWriter(new FileWriter("file1.xml"));
              while ((compsLine = compsConfigFile.readLine()) != null)
                    new_compsLine =compsLine.replaceFirst(find_productstring, replacement_productstring);
                    out.write(new_compsLine);
                    out.write("\n");
                out.close();
                compsConfigFile.close();
                compsFile.delete();
                compsNewFile.renameTo(compsFile);
            catch (IOException e)
            //since "Topabcd" contains "abcd", which is the search above and hence the string "Topabcd" is not replaced correctly
             try
                   String find_producttopstring = "Topabcd";
                   String replacement_producttopstring = "REPLACEMEFIRST";
                   compsXml = new FileReader(compsLoc);
                   compsConfigFile = new BufferedReader(compsXml);
                   File compsFile =new File("file.xml");
                   File compsNewFile =new File("file1.xml");
                   BufferedWriter out =new BufferedWriter(new FileWriter("file1.xml"));
                   while ((compsLine = compsConfigFile.readLine()) != null)
                         new_compsLine =compsLine.replaceFirst(find_producttopstring, replacement_producttopstring);
                         out.write(new_compsLine);
                         out.write("\n");
                     out.close();
                     compsConfigFile.close();
                     compsFile.delete();
                     compsNewFile.renameTo(compsFile);
                 catch (IOException e)
            }Thanks a lot!

    Hi:
    I have a java program that searches and replaces
    strings in a file. It makes a new copy of the file,
    searches for a string in the copy, replaces the
    string and renames the new copy to the original file,
    thereafter deleting the copy.
    Now searching for "abcd", for eg works fine, but
    searching for "Topabcd" and replacing it doesnot work
    because there is a match for "abcd" in a different
    search scenario. How can I modify the code such that
    if "abcd" is already searched and replaced then it
    should not be searched for again or rather search for
    "abcd" as entire string and not if its a substring of
    another string.
    In the below code output, all instances of "abcd" and
    the ones of "Topabcd" are replaced by ABCDEFG and
    TopABCDEF respectively, whereas according to the
    desired output, "abcd" should be replaced by ABCDEFG
    and "Topabcd" should be replaced by REPLACEMEFIRST.
    try
    String find_productstring = "abcd";
    String replacement_productstring = "ABCDEFG";
    compsXml = new FileReader(compsLoc);
    compsConfigFile = new
    BufferedReader(compsXml);
    File compsFile =new File("file.xml");
    File compsNewFile =new File("file1.xml");
    BufferedWriter out =new BufferedWriter(new
    FileWriter("file1.xml"));
    while ((compsLine =
    compsConfigFile.readLine()) != null)
    new_compsLine
    =compsLine.replaceFirst(find_productstring,
    replacement_productstring);
    out.write(new_compsLine);
    out.write("\n");
    out.close();
    compsConfigFile.close();
    compsFile.delete();
    compsNewFile.renameTo(compsFile);
    catch (IOException e)
    //since "Topabcd" contains "abcd", which is
    the search above and hence the string "Topabcd" is
    not replaced correctly
    try
                   String find_producttopstring = "Topabcd";
    String replacement_producttopstring =
    topstring = "REPLACEMEFIRST";
                   compsXml = new FileReader(compsLoc);
    compsConfigFile = new
    gFile = new BufferedReader(compsXml);
                   File compsFile =new File("file.xml");
                   File compsNewFile =new File("file1.xml");
    BufferedWriter out =new BufferedWriter(new
    dWriter(new FileWriter("file1.xml"));
    while ((compsLine =
    compsLine = compsConfigFile.readLine()) != null)
    new_compsLine
    new_compsLine
    =compsLine.replaceFirst(find_producttopstring,
    replacement_producttopstring);
    out.write(new_compsLine);
    out.write("\n");
    out.close();
    compsConfigFile.close();
    compsFile.delete();
    compsNewFile.renameTo(compsFile);
                 catch (IOException e)
    Thanks a lot!I tried the matches(...) method but it doesnt seem to work.
    while ((compsLine = compsConfigFile.readLine()) != null)
    if(compsLine.matches(find_productstring))
         System.out.println("Exact match is found for abcd");
         new_compsLine =compsLine.replaceFirst(find_productstring, replacement_productstring);
    out.write(new_compsLine);
    out.write("\n");
         else
         System.out.println("Exact match is not found for abcd");
         out.write(compsLine);
         out.write("\n");

  • Search and Replace String throwing the wrong error message with regexp?

    This came up in a LAVA thread, and I'm not sure if there's a bug here or not. When using Search and Replace string, and using a regular expression of [(G[b|i])], LabVIEW throws error -4622, "There is an unmatched parenthesis in a regular expression."  There are obviously no unmatched parenthesis in that expression, so it seems to me that the wrong error is being thrown. I'm just not sure if that's a syntactically valid regexp. The problem seems to be with nesting [ ]'s inside ( )'s inside [ ]'s. I've tried a couple of regexp resources on the Web, and one suggests it's valid, while the other seems to think it isn't.
    Message Edited by eaolson on 03-13-2007 10:33 AM
    Attachments:
    ATML_StandardUnit2.vi ‏10 KB
    regexp.png ‏5 KB

    adambrewster wrote:
    I think your regexp is invalid.
    In regexps, brackets are not the same as parentheses.  Parens are for grouping, while brackets are for matching one of a class of characters.  Brackets can not be nested.
    If the regexp is replaced with [G[bi]], there is no error, so it's not a matter of nested brackets. I couldn't find anything on the PCRE man page that forbids nested brackets specifically, but it makes sense.
    Your expression "[(G[bi])]", therefore parses as a character class which matches '(', 'G', '[', 'b', or 'i' followed by an unmatched paren, and an unmatched bracket.
    I don't believe that's the case. Replace the regexp with [(Gbi)], and the error goes away. So it's not a matter of the '(' being literal, and then encountering a ')' without a matching '('.
    daveTW wrote:
    what string exactly you want to replace? I think the round braces are not right in this case, since they mark partial matches which are given back by "match regular expression". But you don't want to extract parts of the string, you want to replace them (or delete, with empty <replace string>). So if you leave the outer [( ... )] then your RegEx means all strings with either "Gb" or "Gi".
    It's not my regular expression. A poster at LAVA was having problems with one of his (a truly frightening one), and this seemed to be the element that was causing the problem. I'm pretty sure that the originator of the regexp meant to use G(b|i), which seems like a complicated way of matching "Gb" or "Gi", if you ask me.

  • Batch File Search and Replace a String

    I've written a batch file to handle the copying of files.  I'm trying to reduce the number of parameters that I pass to the batch file.
    I want the batch file to perform a string replace on the directory path that is passed as a parameter to the batch file.
    Here is how I run the batch file:
    COPY_FILE.BAT C:\DATA\FTP_DATA\ACME\IN      (I'm passing directory path "C:\DATA\FTP_DATA\ACME\IN" as parameter %1)
    So my batch file will copy a file to the directory path represented by parameter %1.
    But then I want the file copied to a second directory.  I want the batch file to replace string "FTP_DATA" in the directory path with string "FTP_DATA\ARCHIVE"
    I know I could pass this path as a second parameter, but I want to limit the number of parameters so figured I could have the batch file perform a search and replace on string "FTP_DATA".
    After searching the internet, I thought I found the answer by using the following command in the batch file:
    set ARCHIVE_PATH=%1:FTP_DATA=FTP_DATA\ARCHIVE
    But it doesn't perform a search and replace.  It just appends to the directory path with the following result:
    C:\DATA\FTP_DATA\ACME\IN:FTP_DATA=FTP_DATA\ARCHIVE
    What I want is the this:
    C:\DATA\FTP_DATA\ARCHIVE\ACME\IN
    Any suggestions?

    Your syntax is not correct. Example:
    @echo off
    setlocal enableextensions
    set ARCHIVE_PATH=C:\DATA\FTP_DATA\ACME\IN
    echo %ARCHIVE_PATH%
    set ARCHIVE_PATH=%ARCHIVE_PATH:FTP_DATA=FTP_DATA\ARCHIVE%
    echo %ARCHIVE_PATH%
    endlocal
    -- Bill Stewart [Bill_Stewart]

  • Joker characters in the search and replace function

    Hello everyone,
    Just a quick question :
    I was wondering what character can be used as a joker character in the search and replace function (I did a research in the site, but didn't find any thread)
    To be clear, I have misspelled a word, for example «trouser».
    I know I didn't make any mistake with the first and last letter, but sometimes I wrote it «tourser», «turoser»
    (sorry if there is a weird meaning, i'm french, and for me it won't mean anything, so don't take it personally)
    I would like to be able te replace all the versions of «trouser», even the good ones, using «t*****r» in the search and replace function.
    I tried the «*» character, but it's not the jocker.
    Thank you for your help !

    As I can't edit my first message, just wanted to let you know it's also called «wildcard» characters
    Like here (Careful, it's… Ms Office)

  • Search and Replace text

    Apologies for what is no doubt a simple question - I'm trying to help out IT and I'm not a programmer, although maybe one day...
    Anyway, I'm going to need to read a text file, and search for a string in that text file and replace it.  I see "replace" as a function but I'm not familiar with how to use it.  Poking around I found <cffile action=append> and used that to add a line to a text document.  (Just a notepad .txt)
    Ultimately I'll need to unzip a folder, search and replace the string in a specific file in there, and then re-zip the file, but we'll get to that later.  I managed to unzip a folder already, that's easy enough.  Putting it all together is my current challenge.
    I'm using ColdFusion Builder 2.0
    Thanks for any help you guys can give.

    file.txt: Contains several lines that all say "All Work And No Play Makes Jack A Dull Boy".
    <cffile action="read" file="C:\file.txt" variable="myFile">
    <cfset myFile = Replace(myFile,"Dull","Bored","all")>
    <cffile action="write" file="C:\file.txt" output="#myFile#" addnewline="no" fixnewline="no">
    <cffile action="read" file="C:\file.txt" variable="myNewFile">
    <cfoutput>#myNewFile#</cfoutput>
    ^_^

  • Search and Replace in Dreamweaver

    Dreamweaver CS3has a nice search and replace tool allowing for search and replacement of very large text strings.
    Does anyone know of a good notepad editor that can handle that large of replace text strings.
    Seems like most cant handle that much code in terms of search and replace.
    thanks

    If you're looking for something free/cheap that handles multi-line search and replace in source code, then there's always TextWranger if you're on a Mac:
    http://www.barebones.com/products/TextWrangler/
    There are plenty of Windows equivalents, but none I've used extensively and could recommend. This one is free:
    http://www.htmlkit.com/
    ...and has a button to expand the find/replace fields for multi-line content.
    That being said, they're not really going to do anything DW can't if you're already using DW.

  • Problem with search and replace

    I'm workin on Windows XP, Dreamwearver 8
    When I do a search and replace in a site, the changes will be
    made correctly, however, the auto date stamp that I'm using on my
    pages will duplicate on random pages and overwrite text This
    doesn't occur on all pages, and isn't connected with the actual
    change I'm making. Has anyone experienced this?

    Ok Gary, but...
    in a SQLWorksheet write:
    ababab
    Now Edit -> Replace search for b , replace with \nb
    Result (the last b is not replaced):
    a
    ba
    bab
    At this point, I want to have my string back on one line: Edit -> Replace search for \n , replace with (nothing here)
    Result: The search text "\n" was not found.
    And to make it work I have to tick the Regular Expressions checkbox (in this case substitute escaped characters is ignored).
    While I agree that "it is good to have a choice", I personally find it confusing: none of the few text editors I use (Linux or OSX) behaves this way.
    Regards.
    Alessandro

  • Search and replace, everey second character?

    I'm making a VI that is communicating with an external device through a protocol built up of frames. I have made a couple of subVIs that put these frames together as hexadecimal strings that are then converted into numbers and passed on to the device. The protocol uses an escape character in order to avoid sending an BOF or EOF constant at the wrong time. I've made a subVI that is supposed to do this using the Serch and Replace function. At first it seems rather elegant, but it has a fatal flaw, if one of the characters it is supposed to hide is written across the edge of a byte, it will still be replaced.
    Example:
    11 01 00 EC 0D EA 05 08
    is replaced by
    11 01 00 E7 DE 0D EA 05 08
    C0, C1, 7D are the characters to be replaced, 7D is the escape character.
    Now I wonder, is it possible to make the search and replace function search only every second character in a string?
    Solved!
    Go to Solution.
    Attachments:
    Insert_Escape_Characters.vi ‏10 KB

    Hi,
    I'm not sure to understand your problem, but I propose this solution !
    Hope it helps you.
    Best regards,
    Vincent
    Message Edité par ramses64 le 02-20-2009 03:57 AM
    V-F
    Attachments:
    replace.PNG ‏17 KB

  • Alternate Search and Replace Tool

    I need to automatically search a piece of HTML code in
    hundreds of help topics. Unfortunately, since RoboHelp's
    "Multi-File Find and Replace" tool doesn't accept carriage returns,
    it won't accept the three-line string of HTML I need to replace.
    Can anyone suggest a (hopefully free) third-party
    search-and-replace tool that won't break RoboHelp in some way? I'm
    a bit worried because I'll be pasting a ton of conditional text
    markers.

    Hi, Adam,
    Two find-and-replace tools that are often mentioned in these
    forums are FAR and BK ReplaceEM. FAR is shareware, but free to use
    for the first two months; BK ReplaceEM is freeware.
    http://www.helpware.net/FAR/index.html
    http://www.snapfiles.com/get/bkreplace.html
    Pete

Maybe you are looking for

  • IPod nano Replacement Program as of 11/14/12

    In case anyone is still wondering what you will receive as a replacement..... as of November 14, 2012 it's a silver 6th generation 8GB iPod nano. It only took 10 days to receive my iPod after requesting it online which is fantastic because I thought

  • Sorry, the all-new Yahoo! Mail does not support your browser.

    Everytime I log into yahoo mail I get this message before proceeding to the e-mail screen. This has been going on for a long time now--as much as a few years, and I want to finally fix it.

  • Total amount/qty of columns in grid/matrix

    Hi, Just want to ask if it is possible to put a total amount/qty of a column in a grid or matrix.

  • AbstractAction - Dynamic Callbacks?

    I'm using AbstractAction for the first time and I'm running into a design/organization issue. I want my Actions to delegate back to the controller when the Action is triggered. So my concrete implementation of AbstractClass takes some kind of interfa

  • Retrieve applet object

    I'm fairly new to Java and I've been concentrating my efforts in applet programming. One thing I've noticed is that I seem to require the Applet object a lot in my code as I'm doing a lot of file reading (applet.getCodeBase, etc). I have a few instan