2011-09-05 4 views
0

나는 VS에 매우 익숙하다. 그리고 C#. 여기에 내가 Richtextbox 있습니다. 나는 두 단어 사이에 내용을 걸러 내고 싶다.리치 텍스트 상자에서 두 단어 사이에 내용 채우기 C#

This is the example way to do my processing. This text is on my Richtextbox

나는 단어 example와 단어 text 사이에 내용을 채우는합니다. 답변은 way to do my processing. This

C#을 사용하여이 작업을 도와주세요.

답변

1

당신은 text 가정, 정규식을 사용하거나 수 귀하를 RichTextBox 텍스트이며,이 코드 :

string from = "example"; 
int iStart = text.IndexOf(from) + from.Length; 
int iEnd = text.IndexOf("text", iStart); 
string result = text.Substring(iStart, iEnd - iStart); 
0

당신은 다음과 같이 수행 할 수 있습니다

string strTest = 
    "This is the example way to do my processing. This text is on my Richtextbox"; 
strTest = strTest.Substring(strTest.IndexOf("example") + 8); 
strTest = strTest.Substring(0,strTest.IndexOf("text")-1); 
0

나는 문제가 밖으로 텍스트를 얻을 생각 를 RichTextBox의 시도 :

var textRange = new TextRange(
    richTextBox.Document.ContentStart, 
    richTextBox.Document.ContentEnd); 
var text = textRange.Text; 

다음을 ...

+0

은'여기 answer'가 _example_ 단어로 시작하는 모든 단어 – Marco

+0

@Marco 필요하지 않습니다 (다른 답변을 참조) : 죄송합니다, 그래 물론. RichTextBox에서 텍스트를 가져 오는 방법에 문제에 집중했습니다. 미안, 내 잘못이야. 오른쪽 하위 문자열을 얻으려면 솔루션이 올바른 방법입니다. – WaltiD

+0

그것은 나에게 같은 일이 일어났습니다 yesyerday :) – Marco

관련 문제