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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:08:33+00:00 2026-06-01T02:08:33+00:00

I dont know how doable this is but I’m working on a datatype for

  • 0

I dont know how doable this is but I’m working on a datatype for an XSD and one of the things I’m trying to do is expand it to allow for a hyphen in a last name. So this should match Smith Fry and Safran-Foer. Additionally, I’d like to limit the length of the string being checked to no more than 100 (or 101) characters. My Regex originaly was:

 <xsd:pattern value="[a-zA-Z ]{0,100}"/>

Now I know I can do something where I break this up and arbitrarily allow 50 characters on either side like:

 <xsd:pattern value="[a-zA-Z ]{0,50}(\-)?[a-zA-Z ]{0,50}"/>

But that seems ungraceful. Is there any way to do something along the lines of:

 <xsd:pattern value="[a-zA-Z (\-)?]{0,100}"/>

Another way of asking for what I’m looking for is ‘Match a string of characters between 0 and 100 long with no more than 1 hyphen in it’.

Thanks!

  • 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-01T02:08:34+00:00Added an answer on June 1, 2026 at 2:08 am

    This is a swing at 'Match a string of characters between 0 and 100 long with no more than 1 hyphen in it' plus some additional constraints:

    • allow for whitespace
    • can’t start or end with a hyphen

    I don’t think you could have the max length done in the pattern considering the syntax supported by XSD regex; it is easy, however, to combine it with a maxLength facet.

    This is an XSD:

    <?xml version="1.0" encoding="utf-8" ?>
    <!--W3C Schema generated by QTAssistant/W3C Schema Refactoring Module (http://www.paschidev.com)-->
    <xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <xsd:element name="last-name">
            <xsd:simpleType>
                <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="100"/>
                    <xsd:pattern value="[a-zA-Z ]+\-?[a-zA-Z ]+"/>
                </xsd:restriction>
            </xsd:simpleType>
        </xsd:element>
    </xsd:schema>
    

    The pattern could be further refined to prohibit a hyphen surrounded by whitespace only, etc.

    Valid XML:

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <!-- Sample XML generated by QTAssistant (http://www.paschidev.com) -->
    <last-name xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/XMLSchema.xsd">last - name</last-name>
    

    Invalid XML (too many hyphens) and message:

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <!-- Sample XML generated by QTAssistant (http://www.paschidev.com) -->
    <last-name xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/XMLSchema.xsd">l-ast - name</last-name>
    

    Validation ERROR:

    Error occurred while loading [], line 3 position 121
    The 'http://tempuri.org/XMLSchema.xsd:last-name' element is invalid - The value 'l-ast - name' is invalid according to its datatype 'String' - The Pattern constraint failed.

    Invalid XML (longer than max, for tests I’ve used maxLength=14) and message:

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <!-- Sample XML generated by QTAssistant (http://www.paschidev.com) -->
    <last-name xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/XMLSchema.xsd">last - name that is longer</last-name>
    

    Validation ERROR:

    Error occurred while loading [], line 3 position 135
    The 'http://tempuri.org/XMLSchema.xsd:last-name' element is invalid - The value 'last - name that is longer' is invalid according to its datatype 'String' - The actual length is greater than the MaxLength value.

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

Sidebar

Related Questions

this is the formular but i dont know how to implement it. can someone
I don't know if this is doable, maybe with Linq, but I have a
I am trying to do something I don't know if it's doable. I have
I dont know if I'm right, but allmost everytime I read about obfuscation and
I dont know what happend but I cant register any dlls anymore. It seems
I dont know where my error is in this mysql query $sql = INSERT
I didn't find a solution for this but I think it should be doable.
I know this question was answered before, but I cant still handle it with
I'm having a bit of a problem, don't even know if this is doable.
string myString = string.Format({0}{1}, foo); This compiles but fails at runtime. I know why,

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.