然后先拆加入一个字符串的一个子集 [英] First split then join a subset of a string

查看:71
本文介绍了然后先拆加入一个字符串的一个子集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有字符串如下:

thumb_634735515600845357tchayat_november_200612.jpg

我想要做的是第一个拆分按_。然后取部分从1到n和加入他们。在这之后

what i want to do is first split by _ . Then take the part from 1 to n and join them.

换句话说,我希望有以下内容:

in other words after this i want to have the following:

634735515600845357tchayat_november_200612.jpg

我知道该怎么做分裂。但后来我如何加入他们吗?

I know how to do split. but then how do i join them ?

我可以循环做。只是好奇,是有这更好的办法

I can do a for loop. just curious is there is a better way to this?

编辑:

我不能有一个子,因为我有拇指_ *

I cant have a substring, because I have data before thumb_*

推荐答案

由于 _ 后拇指总是第一个实例,然后串应符合的IndexOf一起完全可行的。

Since the _ after the thumb is always the first instance then substring should be perfectly viable in conjunction with IndexOf.

string newString = myString.Substring(myString.IndexOf("_") + 1);

这应该采取的子字符串开始处的字符立即按 _ 字符。

This should take the substring starting at the character immediately following the first instance of the _ character.

这篇关于然后先拆加入一个字符串的一个子集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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