ASP.NET/C#/REGEX: Remove items near beginning of string

Using ASP.NET/C#, I want to remove this from a string:

"total_rows":111,"offset":222,

The numbers may change but the other characthers will remain the same.

This
{"total_rows":45,"offset":23,"rows":[]}

Open in new window

Should become this:
{"rows":[]}

Open in new window

LVL 16
hankknightAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

plusone3055Commented:
This should do the trick
string Yournamehere = input.Substring(input.IndexOf(',"rows":[]') + 1);
0
p_davisCommented:
or

 str = string.Format("{{0}" str.Remove(0, str.IndexOf("\"rows\"") + 1);
0
käµfm³d 👽Commented:
using System.Text.RegularExpressions;

...

string result = Regex.Replace(source, @"""total_rows"":\d+,""offset"":\d+,", string.Empty);

Open in new window

0
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

p_davisCommented:
and....... now you have options =)
0
plusone3055Commented:
Variety is the spice of life
0
p_davisCommented:
i thought that was cayenne...
0
käµfm³d 👽Commented:
@p_davis

I think you have an extra starting brace in there.
0
p_davisCommented:
in my example i removed everything at the beginning including the leading brace so I added it back since it was in the op's requirement.
0
p_davisCommented:
I didn't test but I don't think it will confuse the formater.
0
käµfm³d 👽Commented:
The reason I bring it up is because you use a brace to escape a brace in a format string. Based on what you just mentioned, I think you need to add in one more brace:

e.g.

str = string.Format("{{{0}", str.Remove(0, str.IndexOf("\"rows\"") + 1));

Open in new window

0
hankknightAuthor Commented:
Thank you all!  So much help in so little time.

I would also appreciate help with this one:

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_28269635.html
0
p_davisCommented:
man i realy messed that up -- sorry.


 str = str = "{" + str.Remove(0, str.IndexOf("\"rows"));
0
p_davisCommented:
gotta stop free posting.

check your code! check your code! check your code!
0
p_davisCommented:
gar.... and learn how to copy and paste
you don't need the extra str =

str = "{" + str.Remove(0, str.IndexOf("\"rows"));
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.