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

  • SEARCH
  • Home
  • 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 8161667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:32:52+00:00 2026-06-06T18:32:52+00:00

I have some 100 files in which I need to replace: Eval(something) with Eval(something).ToEncodedString()

  • 0

I have some 100 files in which I need to replace:

  1. Eval(“something”) with Eval(“something”).ToEncodedString()
  2. Eval(“something”).ToString() with Eval(“something”).ToEncodedString()

I’m writing a small C# application that can automate this. But unable to form the regular expression. Would somebody help me please?

  • 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-06T18:32:54+00:00Added an answer on June 6, 2026 at 6:32 pm

    You can use this pattern: @"\bEval\(""(?<Value>.+?)""\)(?:\.ToString\(\))?"

    Breakdown:

    • \bEval: match a word-boundary to ensure we match “Eval” as a whole word and not as part of another word
    • \("": literal opening parenthesis and double quotes (the double quotes appear twice since that’s how they’re escaped when using a verbatim string literal, i.e., the @ symbol preceding the string)
    • (?<Value>.+?): named capture group of “Value” which is a non-greedy match of any character (will stop at double quotes)
    • ""\): closing double quotes and closing parenthesis
    • (?:\.ToString\(\))?: the (?:...) bit is a non-capturing group, then we match .ToString() literally with appropriate escaping, and the final ? makes this group optional

    The replacement pattern is @"Eval(""${Value}"").ToEncodedString()", which is easy to understand. The important part is that the named capture group, “Value,” is referenced by using ${Value}.

    Example code:

    string[] inputs = 
    {
        @"Eval(""something"")",
        @"Eval(""hello"").ToString()"
    };
    
    string pattern = @"\bEval\(""(?<Value>.+?)""\)(?:\.ToString\(\))?";
    string replacement = @"Eval(""${Value}"").ToEncodedString()";
    
    foreach (var input in inputs)
    {
        Console.WriteLine(Regex.Replace(input, pattern, replacement));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some larger files which I need to share with people and to
I have some 100 files to be merged from one branch to the other.
In PHP, say that you have some code like this: $infrastructure = mt_rand(0,100); if
I have 100 web servers and noticed that some of them have request filtering
i have written an application, but for some reason it keeps peaking at 100%.
I have a huge ASPX web form which has around 100 fields which need
I have a web application that stores a lot of user generated files. Currently
I have two CSV files (three columns) which I need to compare and extract
I have created a small SIFT application that grabs the keypoints and saves it
I have about 20 .csv files which are around 100-200mb each. They each have

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.