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 6029307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:52:00+00:00 2026-05-23T04:52:00+00:00

I have to move some hard-coded strings to external resources files, and I’m trying

  • 0

I have to move some hard-coded strings to external resources files, and I’m trying to automate the proccess a little bit using regular expressions.

I have some difficulties getting this to work, though.

Sample code excerpt:

    public List<string> GetAllProductIDs()
    {
        var doc = XElement.Load(Path + @"\light.xml");
        var elements = doc.Element("products").Elements("product");
        // (...)

Regular expressions that I use:

  • find what = “{([^”\r]*)}”

(find a string that starts and ends with double apostrophes, and does not contain another double apostrophe, nor a line break, in the middle; and capture it without the first and the last double apostrophe)

  • replace with = Resources.\1

My intention being that

  • Element(“products”)

would become

  • Element(Resources.products)

What happens is

EXPECTED RESULT: the regex does match var doc = XElement.Load(Path + @“\light.xml”);

UNEXPECTED RESULT: the regex does match *var elements = doc.Element(“products “).Elements(“ product”); (which is something I can cope with, I’d just skip it manually)

But it does NOT match “products” nor “product”

Why?

  • 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-05-23T04:52:01+00:00Added an answer on May 23, 2026 at 4:52 am

    The built in Visual Studio regex differs than the more common regex flavors.

    The problem is \r is being interpreted literally rather than as the return control character. There are only a handful of control characters that appear to be supported by the Visual Studio regex flavor and \r isn’t one of them. Therefore, the engine is using it literally.

    To verify this, change \r to \a and you’ll see that it matches “products” and “product” just fine. The reason is that the literal character “a” doesn’t exist in those words, so the match succeeds, whereas the \r made the match fail since the letter “r” does exist in those words.

    To get around this issue you can refer to the return control character by its Unicode hexadecimal value, which is 000D. Change \r to \u000D or to \x0D:

    "{([^"\u000D]*)}"
    

    or

    "{([^"\x0D]*)}"
    

    You might be interested in checking out the Visual Studio Productivity Power Tools, which supports the .NET Regex flavor that most people are used to. Using that tool you would use:

    • Pattern: "([^"\r]*)" note that \r works as expected in this case.
    • Replacement: Resources.$1
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Pylons app where I would like to move some of the
i have a few classes that i am trying to move to using generics
here's what I need (it's a bit hard to explain): I have 2 window
We are using SQL Server 2000 and have to move data across servers to
We have a JavaScript function named move which does just windows.location.href = any given
I have code like this to move the player in my game left, right,
I have the following html.erb code that I'm looking to move to Haml: <span
I have two XmlDocuments and I would like to move an XmlNode selected from
We have an ages old Java applet that we want to move forward to
I have items wrapped in wrap panel. I want to move first line of

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.