infor.com
concierge
infor u
developer portal
documentation central
customer center
Posts
Categories
Groups
ERPs
CSD
FSM/HRT
LN
M3
Syteline/ CSI
Hubs
Developer
Healthcare
Hospitality
Public Sector
Onboarding
Release Center
CloudSuites
Aerospace & Defense (LN)
Automotive (LN)
Chemicals (M3)
Corporate (FSM/HRT)
Distribution (Sx.e/CSD)
Distribution Enterprise (M3)
Engineering & Construction (LN)
Fashion (M3)
Food & Beverage (M3)
Healthcare (FSM/HRT)
Industrial (Syteline/CSI)
Industrial Enterprise (LN)
Manufacturing (M3)
Public Sector (FSM/HRT)
Solutions
Supply Chain Management (SCM)
Human Capital Management (HCM)
Events
Groups
User Groups
Your Groups
About
Email Community Support
Infor News
Migrated Forums
Home
Clovertech
Clovertech Archive
Read Only Archives
Cloverleaf
Cloverleaf
Tcl Question
System
Originally posted by David Harrison
In tcl, how can I check that a variable contains all spaces
Find more posts tagged with
Clovertech
Comments
Tom Rioux
Hi David,
The following should get you what you want:
[regexp \s+ $a]
Hope this helps...
Tom Rioux
System
Originally posted by Anonymous
Are you wanting to know if it only has spaces ?
Or if it has any spaces ?
System
Originally posted by David Harrison
I want to know if its only spaces.
Tom's code works if there are any spaces but also other characters
System
Originally posted by Anonymous
I'm sure there are a dozen ways to do this.
But how about this.
string length [string trim $VAR " "]
If it is zero then it had all blanks or was null
If it has any value then you had non-spaces.
I'm sure Charlie is watching so I'm waiting on his comments on how to improve this. :?:
System
Originally posted by David Harrison
Yes. That's what I eventually came up with - and it works.
Tom Rioux
If you want just a string of spaces, with no characters, then this should do the trick for you:
regexp "^[ ]+$" $a
Example:
hcitcl>set a " "
hcitcl>set b " abc"
abc
hcitcl>regexp "^[ ]+$" $a
1
hcitcl>regexp "^[ ]+$" $b
0
Hope this helps. Thanks John for pointing out the error of my ways. Even when I worked for you, you were (and still are) so good at doing that. I think that makes your day!!! LOL
System
Originally posted by David Harrison
That's the one.
Thanks chaps,
Dave
Charlie Bursell
If you wanted to know if the string consisted of 0 r more spaces simply:
if {[lempty $var]]} { var is empty or only contains spaces }
If you want to make sure it has at least 1 space but nothing else
if {[string length $var] > 0 && ![regexp -- {S} $var]} { var is not empty and contains only spaces}