Options

How to find the position of space in text

Foe example I have a text
demo:='abc bcd def'.

how to find the position of space in the demo?

I have tried using strpos as
STRPOS(demo,' ')
but I always get 0 or 1 as a result.

Best Answer

Answers

  • Options
    abinashphuelabinashphuel Member Posts: 18
    Torben_R. wrote: »
    If you use one more variable it works

    SubString := ' ';
    String := 'abc def';
    strpos(string,substring)

    But main problem in my code was I was trimming all the spaces before getting the position by using delchar("Given String",'=')

    "Given String" := ' abc def efg';
    MESSAGE('---' + "Given String" + '---');
    String := DELCHR("Given String",'=');
    MESSAGE('---' + String + '---');
    
    subString :=' ';
    pos := STRPOS(String,' ');
    MESSAGE(FORMAT(pos));
    

    so later I change code as
    "Given String" := 'abc def efg';
    
    subString :=' ';
    pos := STRPOS(Given String,subString);
    MESSAGE(FORMAT(pos));
    

    OR
    "Given String" := 'abc def efg';
    
    pos := STRPOS(Given String,' ');
    MESSAGE(FORMAT(pos));
    


    Both works for me!

    Thanks
Sign In or Register to comment.