Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on How to trim newline character from a string variable within the QTP forums, part of the Software Testing category; Example having something like, mystring = "animals7[newline]" -> being read from a file msgbox mystring & "TESTING" The above code will display two lines animals7 TESTING How Can I trim ...
|
|||||||
|
|||
|
How to trim newline character from a string variable
Example having something like,
mystring = "animals7[newline]" -> being read from a file msgbox mystring & "TESTING" The above code will display two lines animals7 TESTING How Can I trim the newline away? |
| Sponsored Links |
|
|||
|
Re: How to trim newline character from a string variable
Hi,
First calculate the length of the string received from the file. Then using LEFT() function select the required length of characters. Thanks Gokulakrishnan K |
|
|||
|
Re: How to trim newline character from a string variable
Hi Gokula and others,
Your suggestion will not work well for my cases since the string in the variable is unpredictable. It can have one or more newline characters at the end. I was looking away that I can loop through the string and verify that each character. I think some programing language, there is/are some method to check it such as isInteger() etc. I wonder if I can do that in QTP. |
|
|||
|
Re: How to trim newline character from a string variable
Try with replace
Returns a string in which a specified substring has been replaced with another substring a specified number of times. Replace(expression, find, replacewith[, start[, count[, compare]]]) Arguments expression Required. String expression containing substring to replace. find Required. Substring being searched for. replacewith Required. Replacement substring. start Optional. Position within expression where substring search is to begin. If omitted, 1 is assumed. Must be used in conjunction with count. count Optional. Number of substring substitutions to perform. If omitted, the default value is -1, which means make all possible substitutions. Must be used in conjunction with start. compare Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values. If omitted, the default value is 0, which means perform a binary comparison. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Difference between String.Convert Vs String.ToString | jbanx | C# | 6 | 03-24-2008 01:02 PM |
| Converting single character to string | Geek_Guest | Java | 2 | 08-24-2007 09:42 AM |
| HTML/PDF - Newline Character | psuresh1982 | AJAX & XML | 0 | 07-31-2007 05:37 AM |
| Normal Variable and the Comp-3 Variable in Cobol | Geek_Guest | MainFrame | 0 | 07-04-2007 09:47 PM |
| Trim Function in various Databases | Jim.Anderson | SQL | 1 | 03-18-2007 02:07 AM |