0

I have ${number} 123456789

How to split this so that output is like following-

 *12345 6789*
1
  • Which programming language? Commented Nov 27, 2019 at 5:31

1 Answer 1

4

APPROACH#1 - Uses RF Built-in String and Collections to solve this problem

*** Settings ***
Library           String
Library     Collections

*** Test Cases ***
Case1
        @{characters} = Split String To Characters      123456789
        LOG TO CONSOLE  ${characters}
        ${x} =  Get Slice From List     ${characters}   0       5
        LOG TO CONSOLE  ${x}
        ${s1}=  Evaluate  "".join($x)
        LOG TO CONSOLE  ${s1}

       ${x2} =  Get Slice From List     ${characters}   5       10
        LOG TO CONSOLE  ${x2}
        ${s2}=  Evaluate  "".join($x2)
        LOG TO CONSOLE  ${s2}

APPROACH#2 - Uses RF Built-in Evaluate to solve this problem

*** Settings ***
Library           String
Library     Collections

*** Test Cases ***
Case1
        LOG TO CONSOLE  USING ONLY MATHS
        ${result} =     Evaluate        123456789//10000
        LOG TO CONSOLE  ${result}

        ${result2} =     Evaluate        123456789%10000
        LOG TO CONSOLE  ${result2}
Sign up to request clarification or add additional context in comments.

2 Comments

${a} Get Substring ${number} 0 5 ${b} Get Substring ${number} 5 9 ${c}= Set Variable ${a} ${b} This also is ok i think
Please accept the answer after it has worked for you.stackoverflow.com/help/someone-answers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.