f



Removing all blanks from a string?

I have looked at both STRIP and TRANSLATE and not found what I'm looking for
(but I could have missed it).

I need to remove all blanks (front, middle, and trailing) from a string.

To do this I've a subroutine but am wondering if there is a better way.

Thanks

The routine:

str = strip_blanks(str)
...

strip_blanks: procedure
parse arg str
nstr = ""
do i = 1 to words(str)
nstr = strip(nstr""word(str,i)
end
return nstr

-- 

---------------------------------------------------------
Lionel B. Dyck <><
Home page: http://www.lbdsoftware.com
(replies remove x- and -x from address)


0
Lionel
11/25/2003 3:01:08 AM
comp.lang.rexx 2135 articles. 0 followers. Post Follow

5 Replies
6740 Views

Similar Articles

[PageSpeed] 56

| Lionel B. Dyck wrote:
| I have looked at both STRIP and TRANSLATE and not found what I'm looking for
| (but I could have missed it).
|
| I need to remove all blanks (front, middle, and trailing) from a string.
|
| To do this I've a subroutine but am wondering if there is a better way.
|
| Thanks
|
| The routine:
|
| str = strip_blanks(str)
| ..
|
| strip_blanks: procedure
| parse arg str
| nstr = ""
| do i = 1 to words(str)
| nstr = strip(nstr""word(str,i)
| end
| return nstr

str = space(str,0)   ______________________________________________Gerard S.


0
gerard46
11/25/2003 3:36:45 AM
Thanks - that is perfect.  I've never used the space function before.

-- 

---------------------------------------------------------
Lionel B. Dyck <><
Home page: http://www.lbdsoftware.com
(replies remove x- and -x from address)

"gerard46" <gerard46@rtt.net> wrote in message
news:h7Awb.1203$Uz.37916@news7.onvoy.net...
> | Lionel B. Dyck wrote:
> | I have looked at both STRIP and TRANSLATE and not found what I'm looking
for
> | (but I could have missed it).
> |
> | I need to remove all blanks (front, middle, and trailing) from a string.
> |
> | To do this I've a subroutine but am wondering if there is a better way.
> |
> | Thanks
> |
> | The routine:
> |
> | str = strip_blanks(str)
> | ..
> |
> | strip_blanks: procedure
> | parse arg str
> | nstr = ""
> | do i = 1 to words(str)
> | nstr = strip(nstr""word(str,i)
> | end
> | return nstr
>
> str = space(str,0)   ______________________________________________Gerard
S.
>
>


0
Lionel
11/25/2003 4:50:43 PM
try thi:

newstring = ''
do while oldstring <> ''
    parse var oldstring word oldstring
    newstring=newstring || word
    end

-- 

/s/ Bill Turner, wb4alm


*******  -..-..-.. *** -..-..-.. *** -..-..-.. ***   -. * .  *******
*** ATTN:  This newsgroup has been harvested for email addresses ***
*** and may still be. Sorry for the inconvience, but after being ***
*** on the receiving end of thousands of directly addressed spam ***
*** emails containing virus payloads, I am now forced to provide ***
*** some protection for my communication resources.              ***
***  Please remove the dashes and abracadabra magic to email me. ***
***         Thank you.               /s/ Bill Turner, Wb4alm     ***
*******  -..- * -... * ....- * .- * .-.. * --  ****  .- -.-   ******





Lionel B. Dyck wrote:

> I have looked at both STRIP and TRANSLATE and not found what I'm looking for
> (but I could have missed it).
> 
> I need to remove all blanks (front, middle, and trailing) from a string.
> 
> To do this I've a subroutine but am wondering if there is a better way.
> 
> Thanks
> 
> The routine:
> 
> str = strip_blanks(str)
> ..
> 
> strip_blanks: procedure
> parse arg str
> nstr = ""
> do i = 1 to words(str)
> nstr = strip(nstr""word(str,i)
> end
> return nstr
> 

0
Bill
11/25/2003 5:09:42 PM
"Lionel B. Dyck" <x-lbdyck-x@astound.net> wrote in message
news:bpugtg$aja$1@news.astound.net...
> I have looked at both STRIP and TRANSLATE and not found what I'm looking
for
> (but I could have missed it).
>
> I need to remove all blanks (front, middle, and trailing) from a string.
>
> (snip)

Try SPACE(string,0)

Regards,

Michel Castelein
------------------------------------------------------------
Michel Castelein
MVS, OS/390, and z/OS System Engineer & Education Consultant
e-mail MichelC@jeeves.be
Home page http://www.geocities.com/michelcastelein/
Company: Jeeves Systems Group, phone +32 2 251 66 50
         http://www.jeevessystemsgroup.com


0
Michel
11/25/2003 7:05:42 PM
"Lionel B. Dyck" <x-lbdyck-x@astound.net> wrote in message news:<bpugtg$aja$1@news.astound.net>...
> I have looked at both STRIP and TRANSLATE and not found what I'm looking for
> (but I could have missed it).
> 
> I need to remove all blanks (front, middle, and trailing) from a string.
> 
> To do this I've a subroutine but am wondering if there is a better way.
> 
> Thanks
> 
> The routine:
> 
> str = strip_blanks(str)
> ..
> 
> strip_blanks: procedure
> parse arg str
> nstr = ""
> do i = 1 to words(str)
> nstr = strip(nstr""word(str,i)
> end
> return nstr

Well this could do the trick....

Strip_Blanks: procedure
RETURN ChangeStr(' ',arg(1),'')
0
kjactive
11/26/2003 2:51:10 AM
Reply:

Similar Artilces:

Removing blanks from strings
Hello, I am attempting to implement a function called strsimilarity for object recognition which was developed in my Digital Image Processing using MATLAB text book. However, it requires that only one of the strings has blanks in it. I am having trouble removing the blanks. I have tried using strtrim. I also tried s_boundary1 = num2str(angles_boundary1','s%-d'); however this left one blank in the string. I am not sure why or how this happend. Any help would be appreciated. Thank you Jennifer On 04/12/10 4:59 PM, Jennifer wrote: > I am attempting to implement a...

java.lang.StringIndexOutOfBoundsException: String index out of range: 23 at java.lang.String.charAt(String.java:460)
Hi All I am having the torque3.1.jar and postgresql-7.4. I have compiled the new jdbc driver called as postgresql.jar and have placed it in the lib directory from where the ant scripts catch the jars. Whenever i try to access through torque gestList = BaseGestlistPeer.doSelect(new Criteria()); this error arises java.lang.StringIndexOutOfBoundsException: String index out of range: 23 at java.lang.String.charAt(String.java:460) at org.postgresql.jdbc2.ResultSet.toTimestamp(ResultSet.java:1653) at org.postgresql.jdbc2.ResultSet.getTimestamp(ResultSet.java...

Removing blank line from String
Here is a string with a blank line created when the user hit the enter key twice.. "Type this first Hit enter twice and I am here". How do I compress this String extra blank line so it looks like "Type this first Hit enter twice and I am here" Thanks for any help, Jehan You want to remove the 'extra' blank line or any blank line? You can use StringReader and wrap it within BufferedReader, do a readLine and if the line being read is empty, do not include it in your output. This may not be the best solution if the strings are huge though. -cheers, Manish Jeh...

manipulation of string arrays, removing blanks
So if I have something like this c = 'apples' 'oranges' '' '' '' and I want something like c = 'apples' 'oranges' with no blank spaces at the bottom. IS there a more efficient way to do this then doing a for loop identifying the blank spaces. Thanks again! In article <flu53u$8g6$1@fred.mathworks.com>, Heena D <heenagd@gmail.com> wrote: >So if I have something like this >c = > > 'apples' > 'oranges' > '' > '' > '' ...

Removing the blanks between elements in a string array
Does anyone know a easy to way to print out an array with no blanks at all? I have an array of strings like a = [[' cat,','d o g,','bi rd ' ],[' 1.23, ',' 4. 56,',' 7.89 ']] print, a cat, d o g, bi rd 1.23, 4. 56, 7.89 I can remove most of the spaces with, print, STRCOMPRESS(a, /REMOVE_ALL) cat, dog, bird 1.23, 4.56, 7.89 But what I need to output is, cat,dog,bird 1.23,4.56,7.89 No blanks at all. Any ideas? Thanks, John On Jan 30, 2:31=A0am, "sulli.jj" <sulli...@gmail.com&g...

remove a string from within a string
hi, how can i remove a string from an existing string in javascript. i have a textbox in a form and want to make sure that when the user clicks a button that certain words are moved, like all instances of "hello" should be taken out of the text the user typed in the textbox. any ideas? thank you. *soni29* wrote: > hi, > how can i remove a string from an existing string in javascript. i > have a textbox in a form and want to make sure that when the user > clicks a button that certain words are moved, like all instances of > "hello" should be taken out of ...

test if the string is a blank data string
If I just want to test if a string is blank data string or not. Do you think this method is good enough?? Or any better approach. Please advise. Thanks. public boolean isBlankDataString(String s) { return s.trim().length() == 0; } boolean b = isBlankDataString(" "); > If I just want to test if a string is blank data string or not. Do you > think this method is good enough?? Or any better approach. Please > advise. Thanks. > > public boolean isBlankDataString(String s) > { return s.trim().length() == 0; > } > > boolean b = isBlankDataStrin...

removing a part of a string and converting string to nummber
Hi everybody, I have one particular problem and I hope you cam help me. I have txt file with strings and it looks like this: 'S 1' 'S201' 'S100' 'S 3' 'S 12' 'S210' 'S 11' 'S201' 'S 80' What i would like to do is remove letter "S" and white space(if it is present) in front of the number and convert string to number. Thank you in advance! Nenad On 7/9/2012 9:04 AM, Nenad Polomac wrote: > Hi everybody, > I have one particular problem and I hope you cam help me. > I have t...

Remove all string characters from a string and leave numerics
Hi all, This is a data cleansing issue where I wish to remove all string characters from a string variable called price and convert it into a numeric. The variable comes from a question "How much do you spend a year?" (all strings are uppercase if that helps) I tried COMPUTE newvar=3DREPLACE(price,'A' ,' '). but don't know how to loop or repeat this for all sting characters Also note the last entry is 100-300 so I'd need someway to split them into 2 seperate variables Newvar1 newvar2. Very messy problem I know but any hints or pointers greatly appreciated - hopefully there's an SPSS function i dont know of! DATA LIST LIST /price(A20). BEGIN DATA '=A32000 PER YEAR ' =A31,500.00 'I DONT KNOW' 1200 1200 'DOES NOT KNOW' 10000 'DK' 1516 '2740 APPROX' '=A390 PMONTH' '100-300' END DATA. Regards DaveL On Sep 4, 12:00=A0pm, DaveL <davidll...@mail2lloyd.com> wrote: > Hi all, > > This is a data cleansing issue where I wish to remove all string > characters from a string variable called price and convert it into a > numeric. The variable comes from a question "How much do you spend a > year?" (all strings are uppercase if that helps) > > I tried COMPUTE newvar=3DREPLACE(price,'A' ,' '). =A0but don't know how t= o > loop or repeat this for all sting characters > Also note the las...

removing first occurence of a string in a given string
hi all, is there a way i can identify (to remove) the first occurence of a string in a given string (text variable) i.e. i have values such as 'Block 01' and 'Block 01' --- the 2nd instance has 2 spaces, and i wanna get rid of the first one? thanks On Oct 9, 3:36 pm, "Eversmann Inc." <rifazraz...@gmail.com> wrote: > hi all, > > is there a way i can identify (to remove) the first occurence of a > string in a given string (text variable) > > i.e. > i have values such as 'Block 01' and 'Block 01' --- the 2nd instance >...

string A = string A + string B (adding strings)
Hi, how can I perform the operation of adding string to string. string_A = string_A + string_B In particular I have to do: handles.hsl_current_string{1}(hsl_current_value{1}, :) = [handles.hsl_current_string{1}(hsl_current_value{1}, :), ' ' z1_value, ' ' z2_value, ' ' z_value] where: string_A = handles.hsl_current_string{1}(hsl_current_value{1}, :) string_B = ' ' z1_value, ' ' z2_value, ' ' z_value I am dealing with GUI, string_A is the value of the listbox, and string_B is the value I would like to add to the string_B and rep...

Re: removing first occurence of a string in a given string
Looking at SAS text functions might help.(COMPBL??) -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Eversmann Inc. Sent: Tuesday, October 09, 2007 8:07 PM To: SAS-L@LISTSERV.UGA.EDU Subject: removing first occurence of a string in a given string hi all, is there a way i can identify (to remove) the first occurence of a string in a given string (text variable) i.e. i have values such as 'Block 01' and 'Block 01' --- the 2nd instance has 2 spaces, and i wanna get rid of the first one? thanks ...

Strings, Strings and Damned Strings
I have an int variable (always <100) that I want to convert to a two character string, e.g. if myint = 1, mystr = "01" if myint = 81, mystr = "81" At the moment I can't figure out how to do this cleanly. Then I wish to push a bunch of these strings into an array, for example: typedef char LABEL[3]; LABEL mystrArray[100]; But having read a couple of tutorials I am still no clearer on the best way to do an "array of strings" in this situation, nor how to do it. Any help much appreciated! cheers, Ben Ben wrote: > I have an int variable (always &...

string.fine(string+string...
Hi after reading the docs, I was hoping this would work, but I can't find out why. string a = "I "; string b = "am"; int ego; if(sentence.find((a+b).c_str(),0)!= string::npos) ego++; from the docs **************** size_type find( const string& str, size_type index ); size_type find( const char* str, size_type index ); size_type find( const char* str, size_type index, size_type length ); size_type find( char ch, size_type index ); thanks Gary Wessle <phddas@yahoo.com> writes: > Hi > > after reading the docs, I was hoping this would work, ...

Strings, STRINGS, and crazy strings!
Oh my head... Someone, please bail this choking programmer out of a fix. Here's what I got. 1. A multi-line Textbox control. 2. Enter 3 lines of text (each line separated by hitting the Enter key). 3. In my routine, I transfer the Textbox.text into a string variable, say sString. 4. Then I parse this string with my Parsestring routine that places each individual string into an array called sWords() and the string count into lCount. 5. Next is a For/Next loop to print each string found in sWords() at the same starting point on my Picturebox control (the textbox is in this conta...

string of strings...
I got an array of id's : ids = [22443, 22468, 22371, 22218, 22472, 22377, 22245] I would like to get a string of strings (to be used in SQL WHERE..IN clause " '22443' , ' 22468' , ' 22371' , ' 22218' , '22472' , '22377' , '22245' " If a use ids.join(','), I get "22443,22468,22371,22218,22472,22377,22245" which is obviously not useful for SQL.... is there any shorcuts or should I concatenate each element ? thanks joss On 12/19/06, Josselin <josselin@wanadoo.fr> wrote: > I got an array...

remove from a string
Is there a function in PHP that will remove a blob from inside a string. Similar to the substr() function, but instead of giving me the string I want it to remove the string. For example, I have the string "john goes running" I want to be able to tell it to remove 5 characters starting at position 4, which would get me "john running" Thanks, werdna.si...@gmail.com wrote: > Is there a function in PHP that will remove a blob from inside a > string. Similar to the substr() function, but instead of giving me the > string I want it to remove the string. > >...

removing strings
Hello all, I would like to know if there is a way to remove strings from a text file which contains mostly ascii values. I have a text file which contains numbers and also strings which are actually headings for each collumn. Is there a way search for strings within a txt file and then remove them? I know that one can disregard the first line and then take the rest of the data and store them in an array, but the number of collumns keep changing. and example is given below. Freq(GHz) S11 parameters(db) 1 -0.44534 2 -0.5252 3 -0.23345 Freq(GHz) ...

string + string
Hi any idea why I am getting something like main.cpp:177: error: invalid operands of types ‘const char [11]’ and ‘const char [8]’ to binary ‘operator+’ when trying to compile something like int main(int argc, char* argv[]) { string a = ".........." + "......."; cout << a << endl; } how can I solve this, I have few lines and use + to concatenate them together. thanks Gary Wessle wrote: > Hi > > any idea why I am getting something like > > > main.cpp:177: error: invalid operands of types 'const char [11]' and 'const ch...

String and what is string
Hello All, I noticed that my knowledge of C language is pretty low today. I have the b= elow: char* ytest =3D "*314159 * 10000 ) "; char* xtest =3D " print \"hello, \" + \" world joost\" "; Fig(1) But when I tokenize pointer of character , ytest, I discover that it also t= raverses xtext values. It took me a while to figure this out. And it happen= s when there is space after my last character. For the below it wont happen= .. char* ytest =3D "*314159 * 10000 )"; char* xtest =3D " print \"hello, \" + \" world joost\""; Fig(2) I notice that if I append '\0' to the char variables in fig(1), it works as= expected, that is it wont tokenize xtest varaible. Also if I turn the poin= ter to character varaibles to array (char ytest[]) it works very well. To m= e that means that my compiler appends '\0' for me. But I also noticed that my isspace function fails if I have at the back of= the last character.=20 char* ytest =3D "*314159 * 10000 ) \0"; char* xtest =3D " print \"hello, \" + \" world joost\" \0"; But this works well with isspace function char* ytest =3D "*314159 * 10000 )\0"; char* xtest =3D " print \"hello, \" + \" world joost\" \0";=20 Could someone help me out in figuri...

remove of string
Hi of a char: char filepath[255]; I should remove the last two words: lin.xpl it's a path alike: blal/blaald/lin.xpl so I need something like: blal/ blaald/ How should I do that? Many thanks Michael "Mike" <michael.sgier@gmail.com> wrote in message news:9efc2209-0190-4c7b-8b54-b2fdd2df6a26@5g2000yqj.googlegroups.com=20 > Hi > of a char: char filepath[255]; > I should remove the last two words: lin.xpl > it's a path alike: blal/blaald/lin.xpl so I need something like:=20 > blal/ blaald/ > How should I do that? > Many thanks > M...

when string is not a string
Curious javascript sample. Consider the following code: var s = "asd" var f = function() { return typeof(this) } An expression typeof(s) returns true (as it is expected), but f.call(s) returns false! To make matters worse consider the following snippet: var s = "asd" var f = function() { return this instanceof String } An expression f.call(s) returns true, but (s instanceof String) returns false! The question is why call transforms this to an object? Is it made for unification, e.g. to make this iterable using 'for (var i in this)' loop?...

Blank String
When I do the check if strncmp(blockid,'Z',1)==1 blockid = ''; end it works in Matlab, but does not work when compiled through comtool. Any ideas or suggestions would be appreciated. Thanks Pam W. wrote: > > > When I do the check > > if strncmp(blockid,'Z',1)==1 > blockid = ''; > end > > it works in Matlab, but does not work when compiled through > comtool. > Any ideas or suggestions would be appreciated. > > Thanks I'm not sure what is happening in the compiler (what version ?) but you might want to try: > if i...

Re: removing first occurence of a string in a given string #2
Wow, some one who took the time to write my full name!!! You're welcome! :-) Kumar -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Master Chief Petty Officer John-117 Sent: Tuesday, October 09, 2007 10:54 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: removing first occurence of a string in a given string On Oct 9, 3:36 pm, "Eversmann Inc." <rifazraz...@gmail.com> wrote: > hi all, > > is there a way i can identify (to remove) the first occurence of a > string in a given string (text variable) > > i.e. > ...

Web resources about - Removing all blanks from a string? - comp.lang.rexx

Facebook Removing Outdated School Info from Some Users’ Timelines?
It appears that Facebook is in the process of reminding users that they are no longer in college , as some users are seeing notices that their ...

Removing App Profile Pages
Today, we are announcing that we will remove all App Profile Pages on February 1st, 2012. Though similar in appearance, the automatically generated ...

Friends Checker Tracks Who’s Removing You From Their Facebook Friends List
Last week, Facebook reminded users that when they ignore friend requests the requesting party is not notified, but a new Greasemonkey script ...

Removing the 140-character limit from Direct Messages
If you’ve checked your Direct Messages today, you may have noticed that something’s missing: the limitation of 140 characters. You can now chat ...

How to Removing carrier label on Moto X with Xposed Framework - YouTube
For those of you who do not want to see a carrier label on the Moto X status bar, this mod is for you. Tested on Rogers Moto X, but should work ...

Kmart joins Target in removing GTA5 video game from shelves after online campaign
Target has bowed to pressure from an online campaign calling it to pull popular R-rated video game Grant Theft Auto V from its shelves.

Removing the rorts
Professor John Freebairn, veteran analyst of public policy, believes the Commonwealth spends an unsustainable amount on 'middle-class welfare'. ...

France: officials start removing 1 million 'love locks' from Paris bridges
Paris, known worldwide as the city of romance, on Monday began removing tens of thousands of &quot;love&nbsp;locks&quot;, padlocks chained to ...

Roger Rogerson and Glen McNamara seen on CCTV removing body of Jamie Gao from storage unit
ROGER Rogerson and Glen McNamara were captured on CCTV &#8220;bending, lifting and kneeling down&#8221; as they &#173;removed the body of shooting ...

Bud Light beer ads: “Removing no from vocabulary” outrage - Business News - Business and Finance News ...
US BEER brand Bud Light has apologised and retracted a slogan which suggested having a drink would remove the word &#8216;no&#8217; from your ...

Resources last updated: 3/7/2016 7:10:12 PM