如何从机器人框架中的一行拆分字符串 [英] How to split strings from a line in robot framework

查看:31
本文介绍了如何从机器人框架中的一行拆分字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从变量中获取其余值

${random employee}= 转换为字符串 ${random emp}${replace}= 使用正则表达式删除字符串 ${random employee} ['\\[\\]\\,]${splitline}= 从左侧提取 ${replace} ${SPACE}

输出:

${replace} Alagu kartest1234+3alagu@gmail.cokartest1234+3ramu@gmail.com 开发团队 B3 团队负责人

${splitline} = Alagu

如何从变量 ${replace} 中获取其余值

解决方案

Keyword Split String from String 标准库 就是这样做的.

Split String 字符串,separator=None,max_split=-1

<块引用>

使用 separator 作为分隔符字符串拆分字符串.

如果没有给出 separator,任何空白字符串都是一个分隔符.在这种情况下,可能的连续空格以及前导和尾随空格也将被忽略.

拆分词作为列表返回.如果给定了可选的 max_split,则最多进行 max_split 次拆分,并且返回的列表将具有最大 max_split + 1 个元素.

示例:

@{words} = 拆分字符串 ${string}@{words} = 拆分字符串 ${string} ,${SPACE}

要从 @{words} 获取单个值,请使用通用数组语法:@{NAME}[i].i 是所选值的索引.索引从零开始.

How to get rest of the values from the variable

${random employee}= Convert To String   ${random emp}   
${replace}= Remove String Using Regexp  ${random employee}  ['\\[\\]\\,]

${splitline}=   Fetch From Left ${replace}  ${SPACE}

Output:

${replace} Alagu kartest1234+3alagu@gmail.cokartest1234+3ramu@gmail.com Developer Team B3 Team lead

${splitline} = Alagu

How to get rest of the values from the variable ${replace}

解决方案

Keyword Split String from String standard library does this.

Split String    string, separator=None, max_split=-1

Splits the string using separator as a delimiter string.

If a separator is not given, any whitespace string is a separator. In that case also possible consecutive whitespace as well as leading and trailing whitespace is ignored.

Split words are returned as a list. If the optional max_split is given, at most max_split splits are done, and the returned list will have maximum max_split + 1 elements.

Examples:

@{words} =  Split String    ${string}           
@{words} =  Split String    ${string}       ,${SPACE} 

To get single values from @{words} use common array syntax: @{NAME}[i]. i is the index of the selected value. Indexes start from zero.

这篇关于如何从机器人框架中的一行拆分字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆