如何格式化字符串。 [英] How to format a string.

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

问题描述

嗨专家,



我从文本框中获取一些数据,这些数据可以是以下任何一个数据: -



400vs0102-0103

400-vs-0102-103

400-vs0102-103





我需要的数据是: -



400-vs-0102/0103





先谢谢

Hi Experts,

I am getting some data from textboxes these data these data can be any one from the below fromat:-

400vs0102-0103
400-vs-0102-103
400-vs0102-103


The data i need is:-

400-vs-0102/0103


Thanks in Advance

推荐答案

如果这种格式是固定的,你可以使用蒙面文本方框。

或者,解析前三个字符,检查第四个位置的连字符,如果不存在,则添加一个。

同样,将一个放在第7位如果它不存在。



如果文本的长度是可变的,那么构建解决方案就变得更加困难。

除非你有一些特定的标签要搜索,你将无法建立一个通用的解决方案。
If this format is fixed, you can use a masked text box.
Alternately, parse the first three characters, check for an hyphen in the fourth location and if not present, add one.
Similarly, put one in the 7th position if it is not there.

If the length of the text is variable then it becomes much harder to build a solution.
Unless you have some specific tags to search on, you will not be able to build a generic solution.


这篇关于如何格式化字符串。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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