Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9265353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:03:03+00:00 2026-06-18T14:03:03+00:00

i have a following type of string format — Proposal is given to {Jwala

  • 0

i have a following type of string format —

Proposal is given to {Jwala Vora#3/13} for {Amazon Vally#2/11} {1#3/75} by {MdOffice employee#1/1}

the string contains pair of { } with different positions and may be n number of times.
now i want to replace that pair with other strings which i will compute depending on the string between { } pair.

how to do this ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T14:03:05+00:00Added an answer on June 18, 2026 at 2:03 pm

    You could try regular expressions. Specifically, Regex.Replace variants using MatchEvaluator should do the trick. See http://msdn.microsoft.com/en-US/library/cft8645c(v=vs.80).aspx for more information.

    Something along these lines:

    using System;
    using System.Text.RegularExpressions;
    
    public class Replacer
    {
        public string Replace(string input)
        {
            // The regular expression passed as the second argument to the Replace method
            // matches strings in the format "{value0#value1/value2}", i.e. three strings
            // separated by "#" and "/" all surrounded by braces.
            var result = Regex.Replace(
                input,
                @"{(?<value0>[^#]+)#(?<value1>[^/]+)/(?<value2>[^}]+)}",
                ReplaceMatchEvaluator);
            return result;
        }
    
        private string ReplaceMatchEvaluator(Match m)
        {
            // m.Value contains the matched string including the braces.
            // This method is invoked once per matching portion of the input string.
            // We can then extract each of the named groups in order to access the
            // substrings of each matching portion as follows:
            var value0 = m.Groups["value0"].Value; // Contains first value, e.g. "Jwala Vora"
            var value1 = m.Groups["value1"].Value; // Contains second value, e.g. "3"
            var value2 = m.Groups["value2"].Value; // Contains third value, e.g. "13"
    
            // Here we can do things like convert value1 and value2 to integers...
            var intValue1 = Int32.Parse(value1);
            var intValue2 = Int32.Parse(value2);
    
            // etc.
    
            // Here we return the value with which the matching portion is replaced.
            // This would be some function of value0, value1 and value2 as well as
            // any other data in the Replacer class.
            return "xyz";
        }
    }
    
    public static class Program
    {
        public static void Main(string[] args)
        {
            var replacer = new Replacer();
            var result = replacer.Replace("Proposal is given to {Jwala Vora#3/13} for {Amazon Vally#2/11} {1#3/75} by {MdOffice employee#1/1}");
            Console.WriteLine(result);
        }
    }
    

    This program will output Proposal is given to xyz for xyz xyz by xyz.

    You’ll need to provide your app-specific logic in the ReplaceMatchEvaluator method to process value0, value1 and value2 as appropriate. The class Replacer can contain additional members that can be used to implement the replacement logic in ReplaceMatchEvaluator. Strings are processed by calling Replace on an instance of the Replacer class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following JSON schema { employee: {display_name:EMPLOYEE NAME:, format:string, type:textbox, dflt:null, isMandatory:true}
Hi i have a following huge string format example format : p= --0016367d537a47795e0489ecb3c7\nContent-Type: text/plain;
I have this following code, here CssClass is of the String type. <asp:Panel ID=Panel1
I have following webservice: [webmethod] public string MakeReservation(?? PassengersInfo)//what data type use for PassengerInfo
I have the following JSON String { name:Product, properties: { id: { type:number, description:Product
I have the following method public static void SerializeToXMLFile(Object obj,Type type, string fileName) {
I have a variable which is printed out using the following string format: var
I have the following code: var json = new WebClient().DownloadString(string.Format(@http://www.google.com/dictionary/json?callback=dict_api.callbacks.id100&q={0}&sl=en&tl=en, bar)); This returns something
I have a string string rx; and this string has the following type of
I have the following code in a class: operator string() { return format(CN(%d), _fd);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.