0
string responser = contents.Substring(f + firstTag.Length, g - f - firstTag.Length);
string dateTag = "בתאריך";
string wroteResponser = ":כתב";
int i = responser.IndexOf(dateTag);
int p = responser.IndexOf(wroteResponser );
string test = responser.Substring(i + dateTag.Length, p + wroteResponser.Length - i - dateTag.Length);

In responser i have: כתב: רוטרית בתאריך: 26.06.14 שעה: 22:58 I want to remove from it this part: כתב: רוטרית

So in the end i will end with this only: בתאריך: 26.06.14 שעה: 22:58 The way im doing it p is -1 all the time and also test i think is wrong.

0

3 Answers 3

1

the reason p = -1 is because wroteResponser should be "כתב:" and not ":כתב" however, your whole premise is wrong.

you are looking to remove parts.

            string responser = "כתב: רוטרית בתאריך: 26.06.14 שעה: 22:58 ";
            string dateTag = "בתאריך";
            string wroteResponser = "כתב:";
            int i = responser.IndexOf(dateTag);
            int p = responser.IndexOf(wroteResponser);


            string test = responser.Remove(p, i);

another solution would be with regular expressions

        var match = Regex.Match(responser,"כתב: .+בתאריך:(.+) ",RegexOptions.Compiled);
        var u = match.Groups[1].Value;

לילה לבן שמח ;)

Sign up to request clarification or add additional context in comments.

1 Comment

תודה מיקי בדיוק חזרנו עכשיו מהלילה הלבן בתל אביב :)
1

Why don't you use String.Replace("stringyouwantremoved", ""); This will return the original string minus the string you want removed.

2 Comments

I forgot to mention that this responser is in a loop in this example it contain כתב: רוטרית בתאריך: 26.06.14 שעה: 22:58 but in the next itertion it can contain for example: כתב: משה בתאריך: 26.06.14 שעה: 22:58
What is changing all the time is the name: רוטרית then משה so i need to find how to remove each time: :כותב + the name
0

Int start = 0;

Int end =[ some number] ;

String test = response. Remove(start, end) ;

Something like that should work unless I am just not understanding the question.

4 Comments

I forgot to mention that this responser is in a loop in this example it contain כתב: רוטרית בתאריך: 26.06.14 שעה: 22:58 but in the next itertion it can contain for example: כתב: משה בתאריך: 26.06.14 שעה: 22:58
What is changing all the time is the name: רוטרית then משה so i need to find how to remove each time: :כותב + the name
Then do the same thing but use indexOf()
LOOP{Int start = response. indexOf([what you are looking for]) ; Int end =response. indexOf() ; String test = response. Remove(start, end) ;} END LOOP

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.