且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在VB.NET中的两个其他字符串之间插入一个字符串?

更新时间:2022-12-29 10:44:33

这不是一个问题,我们可以说做这个并将其全部排除。

为什么不呢?好吧,想一想。为什么我是介于Hello和autotroph之间?如果方框以Hello开头怎么办?或者Hello autotroph,或Hello,我是autotrophe? 快速的棕色狐狸跳过懒狗怎么样?



机械上它很简单:一个正则表达式,string.Replace,Substring,甚至只是字符串。拆分和string.Join会这样做 - 问题是定义它应该工作的规则。而你还没有这样做。所以首先要考虑它为什么要完成以及它在哪里完成,这应该开始引导你进入一个算法,它应该给你一个实现计划。
It's not a question where we can say "do this" and it sorts it all out.
Why not? Well, think about it. Why does "I'm" go between "Hello, " and "autotroph."? What if the box starts with "Hello"? Or "Hello autotroph", or "Hello, I'm autotrophe"? How about "The quick brown fox jumps over the lazy dog"?

Mechanically it's simple to do: a Regex, string.Replace, Substring, or even just string.Split and string.Join will do it - the problem is defining the rules by which it should work. And you haven't done that. So start by thinking about why it gets done and where it gets done, and that should start to lead you to an algorithm, which should give you a plan for implementation.