如何清理本规范 [英] How to Clean Up This Code

查看:69
本文介绍了如何清理本规范的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何清理此代码?它有效,但它像一盘意大利面。欢迎任何建议。该函数的目标是将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...


这篇关于如何清理本规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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