搜索文件中的字符串 [英] Search a String in a file

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

问题描述

我正在将文本文件内容读取为字符串.
我想用其他字符串替换第一次出现的字符串,然后使用其他字符串替换第二次出现的字符串.

I am reading text file content into a string.
I want to replace first occurrence of a string with some other string second occurrence with some other string.
Is it possible to find first occurrence of a string in a file?

推荐答案

使用String类的IndexOf方法检查字符串的首次出现. > 请参阅此链接
http://msdn.microsoft.com/en-us/library /system.string.indexof(VS.100).aspx [
Using the IndexOf method of String class to check for the first occurrence a string.
Refer this link
http://msdn.microsoft.com/en-us/library/system.string.indexof(VS.100).aspx[^]


您好,

Google It您将得到答案.
Hello ,

Google It You will get Answer.
Search a String


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

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