英文:
Azure logic app extract 2nd line from body
问题
我需要从消息正文中提取一个包含重要服务名称的消息正文,该服务名称是纯文本。我需要将整行提取到一个新字段中。在Azure逻辑应用中如何实现这一点。
示例数据
%%%
DB-Service-Name
Line1
Line2
我只需要在一个新字段中提取消息正文的第二行,名称为Service-Name。
英文:
I have a body message body which contains an important service name in the body of the message which is plain text. I need to extract that whole line into a new field. how can this be achieved in Azure logic app.
Sample data
%%%
DB-Service-Name
Line1
Line2
I only need to extract the 2nd line from the message body in a new field Service-Name
答案1
得分: 1
你需要使用分割操作,如@skin所提到的。我已经从我的一侧重现了问题,以下是我遵循的步骤:
- 创建逻辑应用如下所示,并分配
%%%
DB-Service-Name
Line1
Line2
它在一个初始化变量中。
-
接下来,采用另一个初始化变量,如下所示,根据换行符拆分行,表达式为
split(variables('Service'),'\n')注意:确保你在代码视图中添加这个表达式,因为逻辑应用默认附加'\'。
接下来,采用另一个初始化变量如下所示,以获取第二个值,表达式为,
split(variables('Service-Name'),',')[1]
逻辑应用成功运行如下所示。
最终初始化变量的输出。
英文:
you need to use split action as mentioned by @ skin. I have reproduced issue from my side and below are steps I followed,
- Created logic app as shown below and assigned
%%%
DB-Service-Name
Line1
Line2
it in a initialize variable.
-
Next taken another initialize variable as shown below to split lines based on new line and the expression is
split(variables('Service'),'\n')Note: Make sure you add this expression in code view as logic app by default append '\'.
Next taken another initialize variable as shown below to get second value and the expression is,
split(variables('Service-Name'),',')[1]
logic app ran successfully as shown below.
Output of final initialize variable.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论