Line breaks in strings in LabVIEW are caused by
termination characters, ASCII character symbols which the computer running your code interprets as various kinds of line breaks. In order to remove the line breaks from a string, you'll first need to determine what kind of line breaks your string contains. The most common type of line break used in strings on Windows systems is an
End of Line character, represented as \r\n in ASCII, but it's possible that your string contains a different kind of line break. you can determine what kind of line break is present in your string by inserting the string into a constant, indicator, or control and changing the display format to Backslash (\) Codes using the right-click menu or the object's Properties window. In the case of the example string in this article, the line break character is a
Line Feed character.
Once you have determined the type of line break present in your strings, you can use the
Search and Replace Pattern VI present in the
Additional String VIs and Functions Palette to search your strings for that character and replace it with an
Empty String constant. An example of this implementation, and various stages of the output, are shown below.
If you know your strings will only have one line break in them, you can use this method without modification. However, if you're unsure of how many line breaks a given string will have, you need to add a way to search the string multiple times for line break characters, as the Search and Replace Pattern VI only replaces the first pattern found. One example of how to implement this using a While Loop and the
Match Pattern function is shown below.