Forum Discussion

calliper_143911's avatar
calliper_143911
Icon for Nimbostratus rankNimbostratus
Oct 29, 2014

Find whitespace in string

Hi,

 

I have a string: set stringvar ["apple", "pear", "tomato" "grape", "banana", "strawberry"]

 

How can I find the position of the double-space between tomato and grape? When I try: [string first {" "} $stringvar] It returns -1. I've also tried { } and {\" \"}

 

Many thanks.

 

  • kunjan's avatar
    kunjan
    Icon for Nimbostratus rankNimbostratus

    Seems to be working

    % set stringvar {"apple", "pear", "tomato"  "grape", "banana", "strawberry"}
    "apple", "pear", "tomato"  "grape", "banana", "strawberry"
    % string first {"  "} $stringvar
    24
    %