OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Solve: Remove leading or traling space (NewBie)

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
zizi
General User
General User


Joined: 04 May 2012
Posts: 14

PostPosted: Sat May 05, 2012 4:09 am    Post subject: Solve: Remove leading or traling space (NewBie) Reply with quote

Hi,

I am new to macros and I am trying to learn how to remove leading or trailing spaces from strings. One way is to use split. The problem of doing so is that at times, I need the middle space. For example, Zizi Nathan where I need the space between Zizi and Nathan but the front space and last space is removed.

Any hint to get me started is appreciated.

Many thanks,
zizi


Last edited by zizi on Sun May 06, 2012 6:05 am; edited 1 time in total
Back to top
View user's profile Send private message
patel
Power User
Power User


Joined: 14 Apr 2012
Posts: 54
Location: Italy

PostPosted: Sat May 05, 2012 6:40 am    Post subject: Reply with quote

can you attach a sample ?
_________________
If your problem has been solved please add "[Solved]" to the beginning of your first post title (edit button).
Back to top
View user's profile Send private message
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 9183
Location: Lexinton, Kentucky, USA

PostPosted: Sat May 05, 2012 10:18 am    Post subject: Reply with quote

Code:
Sub Main
ss = " s "
ss = Trim(ss)
print len(ss) ' = 1
End Sub

You can also use Ltrim or Rtrim.
Back to top
View user's profile Send private message
zizi
General User
General User


Joined: 04 May 2012
Posts: 14

PostPosted: Sun May 06, 2012 6:05 am    Post subject: Reply with quote

Thanks a lot.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group