开发者

TextRange Find string c#

开发者 https://www.devze.com 2023-03-17 09:56 出处:网络
Im looking for a function that will enable me to find a certain string in a textRange and gives me back its textPointers(beginning and end)

Im looking for a function that will enable me to find a certain string in a textRange and gives me back its textPointers(beginning and end) whats the best approach or is there any textRange method that can help me ? Thanks.

I have a problem in my approach which happens when i have same words in my textRange and im trying to get the Textpointer for each word in the textRange.

For example my text in the textRange is

"hello hello hello"

and i want to get the text pointer for each word in the textRange, it will mix the second开发者_如何学Python and last word and give me (the first indexOf the word) or last depends on which method i use.


Something like this

string txt = tr.Text; //tr is your TextRange
string find = "a str";
int beginPtr = txt.IndexOf(find);
int endPrt = beginPtr + find.Length;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号