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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:46:40+00:00 2026-05-13T21:46:40+00:00

Processing time doubles as Y goes to the right. Can anybody tell me why?

  • 0

Processing time doubles as “Y” goes to the right.
Can anybody tell me why? How to solve this problem?

I have many big ID’s stored in a database those can’t be changed so I can’t limit the size too much.

using System;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Schema;

namespace TestRegex
{
 class Program
 {
  static void Main(string[] args)
  {

   DateTime start = DateTime.Now;

   /******************************************
    *  ID to validate
    ******************************************/
   //string id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // Ok: Fast
     string id = "xxxxxxxxxxxxxxxxxxxxxYxxxxxxx"; // Invalid: Slow
   //string id = "xxxxxxxxxxxxxxxxxxxxxxYxxxxxx"; // Invalid: Slower
   //string id = "xxxxxxxxxxxxxxxxxxxxxxxYxxxxx"; // Invalid: Very slow
   //string id = "xxxxxxxxxxxxxxxxxxxxxxxxYxxxx"; // Invalid: Very very slow

   /******************************************
    *  XML to validate
    ******************************************/  
   XmlDocument doc = new XmlDocument();
   doc.LoadXml("<root id='" + id + "'></root>");

   /******************************************
    *  XSD validator
    ******************************************/
   string xsl =
@"
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'
           elementFormDefault='unqualified'
           attributeFormDefault='unqualified'>

 <xs:simpleType name='id'>
        <xs:restriction base='xs:string'>
            <xs:pattern value='^([a-z_]+[0-9]*)+' />
        </xs:restriction>
 </xs:simpleType>

    <xs:element name='root'>
        <xs:complexType>
            <xs:attribute name='id' use='required' type='id' />
  </xs:complexType>
 </xs:element>
</xs:schema>
";

   /******************************************
    *  Adds XSD to XML and validates it
    ******************************************/
   XmlTextReader reader = new XmlTextReader(
    new MemoryStream(ASCIIEncoding.Default.GetBytes(xsl)));

   XmlSchema schema = XmlSchema.Read(reader, new ValidationEventHandler(Validate));
   doc.Schemas.Add(schema);
   doc.Validate(new ValidationEventHandler(Validate));


   /******************************************
    *  Performance results
    ******************************************/
   Console.WriteLine(id.Length + " = " + (DateTime.Now - start).TotalSeconds);
   Console.Read();
  }

  private static void Validate(object o, ValidationEventArgs args)
  {
   if (args.Exception != null)
   {
    Console.WriteLine(args.Exception);
   }
  }
 }
}
  • 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-13T21:46:40+00:00Added an answer on May 13, 2026 at 9:46 pm

    Solved!

    The regex ^([a-z_][a-z_0-9]*) has the same behavior and it’s extremely faster.

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

Sidebar

Related Questions

I have a complex action which can take a long time to run. If
Ok, so I have been searching for quite some time on this. I have
I have a problem understanding some code fragment from Matlab Signal processing Toolbox fir2()
I'm creating a non-intrusive popup window to notify the user when processing a time-consuming
Is there an image processing algorithm that can fill these gaps within an image?
I am writing a library for efficient number processing. I have to support different
This is what I am doing, which works 99.999% of the time: ((int)(customerBatch.Amount *
For the life of my, I can't figure out this performance hit in my
I've been battling with this for some time and seem to be getting nowhere.
I am trying to solve a problem in Objective-C, but I don't think the

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.