得到一个字符串的一部分 [英] get a part of a string

查看:59
本文介绍了得到一个字符串的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我在c#中开发(在SSIS脚本任务中,所以正常的C#)。

I am developing in c# (inside a SSIS script task, so normal C#).

我有一个变量FileName 它将采用如下值: " 13_SECURITY_CODE_MAP_D_5011R.07_20171128.csv"

I have a variable FileName which will assume a value like : "13_SECURITY_CODE_MAP_D_5011R.07_20171128.csv"

我想要另一个变量来选择这个文件名变量的一部分的值

I would like another variable to pick the value of just one part of this filename variable

所以基本上我想要

1)  要更换 这部分(总是一样的)   " 13_SECURITY_CODE_MAP_D_" 我可以使用内置的替换功能来做到这一点。

1)  To replace  this part (which is always the same)   "13_SECURITY_CODE_MAP_D_"  and I can do this with the built in replace function.

2)   我想要骑车在点之后的所有工作人员,所以在这种情况下: " .07_20171128.csv"

2)   I want to get ride of all the staff after the dot , so in this case: ".07_20171128.csv"

目标是保持只是   在这个新变量中,"13_SECURITY_CODE_MAP_D_"之间是什么?和"。"

Goal is to keep just  in this new variable what is between "13_SECURITY_CODE_MAP_D_" and the "."

你能帮我理解我该怎么办?您能否提供一些代码示例?

Can you help me understand how can I do this? Can you provide me kind of a sample of code?

谢谢 

PR

推荐答案

有一种替换方法

There is a replace method

x = x.Replace(" OldStringToReplace"," Replacement");

x = x.Replace("OldStringToReplace", "Replacement");


这篇关于得到一个字符串的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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