在字符串中查找字符 [英] Finding Character in String

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

问题描述

我想从字符串的末尾返回图形文件(DWG)的名称。

字符串的长度各不相同......以及图形文件名

本身。


我可以通过获取字符串的长度来完成它,并且

一次减去一个字符直到我点击''\''字符...然后

我会知道要减去多少来获取我的文件名。


该字符串的一个示例是:

" P:\Projects \\\2004 \ 10-02-230(ProjectName \600 Drawings\E101.dwg"


但是在我的字符串中搜索最后一个''\''字符

是否有更简单(更快)的方式?(请记住''的数量'' \''在每个字符串中也会

变化)。


提前致谢!


问候,


布鲁斯

I want to return the name of the drawing file (DWG) from the end of a string.
The string will be of varying lengths... as well as the drawing file name
itself.

I could do it the long way by getting the length of the string, and
subtracting one character at a time until I hit the ''\'' character... then
I''ll know how much to subtract to get my file name.

An example of the string is:
"P:\Projects\2004\10-02-230 (ProjectName\600 Drawings\E101.dwg"

But is there an easier (and faster) way to search for the last ''\'' character
in my string? (keep in mind that the number of ''\'' in each string will also
vary).

Thanks in advance!

Regards,

Bruce

推荐答案

B先生,


看看instrrev的功能。


HTH,


Bernie Yaeger


"先生。 B" < US ** @ NoWhere.com>在消息中写道

news:7o ******************************** @ 4ax.com ...
Hi Mr B,

Take a look at the instrrev function.

HTH,

Bernie Yaeger

"Mr. B" <Us**@NoWhere.com> wrote in message
news:7o********************************@4ax.com...
我想从
字符串的末尾返回图形文件(DWG)的名称。字符串将具有不同的长度...以及图形文件名
本身。

我可以通过获取字符串的长度来做很长的事情,并且
一次减去一个字符,直到我点击''\''字符...然后
我知道要减去多少来获取我的文件名。

该字符串的示例是:
" P:\Projects \\\2004 \ 10-02-230(ProjectName \ 600 Drawings\E101.dwg"

但是有吗在我的字符串中搜索最后一个''\''
字符的更简单(更快)的方式?(请记住,每个字符串中''\''的数量也是
也是提前感谢。

提前致谢!

问候,

布鲁斯
I want to return the name of the drawing file (DWG) from the end of a string. The string will be of varying lengths... as well as the drawing file name
itself.

I could do it the long way by getting the length of the string, and
subtracting one character at a time until I hit the ''\'' character... then
I''ll know how much to subtract to get my file name.

An example of the string is:
"P:\Projects\2004\10-02-230 (ProjectName\600 Drawings\E101.dwg"

But is there an easier (and faster) way to search for the last ''\'' character in my string? (keep in mind that the number of ''\'' in each string will also vary).

Thanks in advance!

Regards,

Bruce



* B先生< Us ** @ NoWhere.com> scripsit:
* Mr. B <Us**@NoWhere.com> scripsit:
我想从字符串的末尾返回图形文件(DWG)的名称。
字符串的长度各不相同......以及图形文件名
本身。

我可以通过获取字符串的长度来完成它,并且
一次减去一个字符直到我点击''\''字符...然后
我知道要减去多少来获取我的文件名。
I want to return the name of the drawing file (DWG) from the end of a string.
The string will be of varying lengths... as well as the drawing file name
itself.

I could do it the long way by getting the length of the string, and
subtracting one character at a time until I hit the ''\'' character... then
I''ll know how much to subtract to get my file name.




请改用''System.IO.Path.GetFileName'。


-

Herfried K. Wagner [MVP]

< URL:http://dotnet.mvps.org/>



Use ''System.IO.Path.GetFileName'' instead.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


借助Deft Fingers,B< Us ** @ NoWhere.com>写道:
With Deft Fingers, Mr. B <Us**@NoWhere.com> wrote:
我想从字符串的末尾返回图形文件(DWG)的名称。
字符串的长度也各不相同......作为图纸文件名
本身。
I want to return the name of the drawing file (DWG) from the end of a string.
The string will be of varying lengths... as well as the drawing file name
itself.




呀!谢谢所有......有很多选择可供选择......我会尝试所有这些......

看看我得到了什么。


非常感谢!


布鲁斯



Yeow! Thanks ALL... so many options to choose from... I''ll try them all and
see where I get.

Thanks muchly!

bruce


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

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