"i have completed capturing the value from lsec line, and when i tried to replace _00_ in lsbsec, program replacing all the values.
Actually it has to replace only till next lsec starts. i wrote a condition And it is not a loop program."
So presumably you are using String.Replace?
That won't work too well - the replace method has no upper or lower bounds you can set to limit the replace operation to a selected portion of the text.
There are a couple of ways you can do this.
If you are trying to replace a single section only, then I would locate the start
line, located the end
line, then cut the input string into three parts before changing the single section and rebuilding it.
If you have multiple sections to do, then I would suggest one of two routes:
1) Use String.Split to break the text into sections starting with a
section, and use String.Replace to update each. Then use String.Join to rebuild the output.
2) Use a Regex - there is a version of the Regex.Replace method which uses a MatchEvaluator method to update each instance of the replace string which you could use to match your
lines. It would be a faff to get right I suspect, but it would be an easy to maintain version. I use this for string parameter replacement: Advanced Regex.Replace handling
] - the link won't solve your problem, but it shows what I do with the match evaluator, and how easy it is to set up.