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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:19:15+00:00 2026-06-03T03:19:15+00:00

I have an XML Schema that I’m trying to create C# classes with. At

  • 0

I have an XML Schema that I’m trying to create C# classes with. At the moment, I’m working with XSD2Code to create the classes. The original schemas have elements that look something like this:

<xs:element name="NumberOfTags" type="xs:positiveInteger" minOccurs="0">
    <xs:annotation>
        <xs:documentation>ALT\N</xs:documentation>
    </xs:annotation>
</xs:element>

XSD2Code produces code that looks something like this:

/// <summary>
/// ALT\N
/// </summary>
public string NumberOfTags { get; set; }

The XML comment refers to a TMATS CODE that maps to a different data representation. I need to capture these codes in some sort of runtime-readable representation so that I can perform this mapping programmatically. My best idea to achieve this so far is to translate these XML comments to C# Attributes, and write additional code to reflect over them.


So here is my question. I would like to do a regex-style replace on the code generated by XSD2Code, using Visual Studio Find and Replace, so that the resulting code looks like this:

[TmatsCode(@"ALT\N")]
public string NumberOfTags { get; set; }

What is the regex that would achieve 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-03T03:19:16+00:00Added an answer on June 3, 2026 at 3:19 am

    using Visual Studio Find and Replace

    Using Visual Studio’s Find & Replace, you can use this expression:

    ^.*\<summary\>\n{:b*}///:b*{.*}\n.*\<\/summary\>$
    

    And this replacement:

    \1[TmatsCode(@"\2")]
    

    To break it down:

    • ^.*\<summary\>\n – Match on the beginning of a line, any amount of characters uptil followed by a new line.
    • {:b*}/// capture any whitespace up til the the /// characters. We’ll later use this captured whitespace so we can indent the attribute correctly.
    • :b*{.*} match any whitespace, then capture the remainder as the content we want.
    • \n.*\<\/summary\>$ match on the new line, then till the end of the line of the closing summary element.

    For the replacement, \1 is the whitespace we captured so the attribute is indented to the same place, and \2 is the summary content.

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

Sidebar

Related Questions

I have a XML schema that I will need to create Java classes for.
I have a custom XML schema defined for page display that puts elements on
I have an XML schema that uses enumerations, but when I look at the
I have an XML schema that includes multiple addresses: <xs:element name=personal_address maxOccurs=1> <!-- address
I have an XML schema that represents a product in a DB, and I
I have a xml blob that's checked against a schema in sql 2005. My
I have an xml message that is in the older schema (xsd) format. My
I have to make a schema for an XML format that's already being used.
I have an XML Schema that mostly makes sense, but I encountered a bit
I have an XML Schema that looks like this: <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema> <xs:element name=root> <xs:complexType>

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.