如何清理本规范

编程入门 行业动态 更新时间:2024-10-26 01:20:03
本文介绍了如何清理本规范的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何清理此代码?它有效,但它像一盘意大利面。欢迎任何建议。该函数的目标是将strOrig解析为预期结果。当然strOrig会有所不同,但总是采用相同的格式。

How can I clean up this code? It works but it resembles a plate of spaghetti. Any advice is welcome. The goal of the function is to parse strOrig into Expected Results. Of course strOrig will vary, but will always be in the same format.

展开 | 选择 | Wrap | 行号 推荐答案

你能提供样本输入和输出吗?覆盖预期的两个或三个? Can you provide a sample input and output maybe two or three that covers the expected?

样本输入是:AB000001; | Folder01 | Tag01 | Tag02 |; | Folder02 | Tag01 | T ag03 |;" 预期结果是: " AB000001; Folder01 [delim] Tag01; Folder01 [delim] Tag02; Folder02 [delim] Tag01; Folder02 [delim] Tag03" 另一个示例输入是: " AB000001; | Folder01 | Tag01 | Ta g02 |; | Folder02 | Tag01 | T ag03 |; | Folder03 | Tag04 | Tag05 |;" 对于此示例,输出为: " AB000001; | FOLDER01 | [DELIM] | Tag01 |; | FOLDER01 | [DELIM] | Tag02 |; | Folder02 | [DELIM] | Tag01 |; | Folder02 | [DELIM] | Tag03 |; | FOLDER03 | [DELIM] | Tag04 |; | Folder03 | [delim] | Tag05 |;" 我要用[delim]替换真正的分隔符,所以这只是一个占位符,直到我们决定使用哪个分隔符。此函数的输入数据将是一个分隔的文本文件,因此我需要设计数据库来处理多行。 感谢您的回复。 The sample input is: "AB000001;|Folder01|Tag01|Tag02|;|Folder02|Tag01|T ag03|;" The expected results are: "AB000001;Folder01[delim]Tag01;Folder01[delim]Tag02;Folder02[delim]Tag01;Folder02[delim]Tag03" Another sample input is: "AB000001;|Folder01|Tag01|Tag02|;|Folder02|Tag01|T ag03|;|Folder03|Tag04|Tag05|;" For this sample the output would be: "AB000001;|Folder01|[delim]|Tag01|;|Folder01|[delim]|Tag02|;|Folder02|[delim]|Tag01|;|Folder02|[delim]|Tag03|;|Folder03|[delim]|Tag04|;|Folder03|[delim]|Tag05|;" I am going to substitute a real delimiter for [delim], so that is just a placeholder until we decide which delimiter to use. The input data for this function will be a delimited text file so I''ll need to design the database to handle multiple rows. Thanks for your response.

我会使用几个数组和拆分来处理这个...... I''d use a couple of arrays and the split to handle this...

更多推荐

如何清理本规范

本文发布于:2023-11-23 09:03:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1620866.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!