473,756 Members | 8,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xsd regular expression query

I have a regular expression that allows only certain characters to be
valid in an xml doc as follows:

<xs:pattern value="^[ dgHhMmstyf,\-\./:;\\]*" />

What I want to do is also allow any unicode character that is enclosed
in single quotes to also be valid, no matter where they appear. I
tried the following:

<xs:pattern value="^[ dgHhMmstyf,\-\./:;\\]*('*)*" />

But this only works if the characters in quotes appear after the other
text.

Any help would be much appreciated.

Regards
Rory

Mar 30 '07 #1
6 2861
* ro****@gmail.co m wrote in comp.text.xml:
>I have a regular expression that allows only certain characters to be
valid in an xml doc as follows:

<xs:pattern value="^[ dgHhMmstyf,\-\./:;\\]*" />

What I want to do is also allow any unicode character that is enclosed
in single quotes to also be valid, no matter where they appear. I
tried the following:

<xs:pattern value="^[ dgHhMmstyf,\-\./:;\\]*('*)*" />

But this only works if the characters in quotes appear after the other
text.
You are looking for "(a character from a certain set, or the character '
followed by zero or more characters except the character ' followed by
the character ') zero or more times", i.e. something like

([a-z]|'[^']*')*

if the first set of characters was a-z.
--
Björn Höhrmann · mailto:bj****@h oehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Mar 30 '07 #2
On Mar 30, 2:02 pm, Bjoern Hoehrmann <bjo...@hoehrma nn.dewrote:
* ror...@gmail.co m wrote in comp.text.xml:
I have a regular expression that allows only certain characters to be
valid in an xml doc as follows:
<xs:pattern value="^[ dgHhMmstyf,\-\./:;\\]*" />
What I want to do is also allow any unicode character that is enclosed
in single quotes to also be valid, no matter where they appear. I
tried the following:
<xs:pattern value="^[ dgHhMmstyf,\-\./:;\\]*('*)*" />
But this only works if the characters in quotes appear after the other
text.

You are looking for "(a character from a certain set, or the character '
followed by zero or more characters except the character ' followed by
the character ') zero or more times", i.e. something like

([a-z]|'[^']*')*

if the first set of characters was a-z.
--
Björn Höhrmann · mailto:bjo...@h oehrmann.de ·http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 ·http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 ·http://www.websitedev.de/
Not quite - I want to allow the character(s) in quotes to be able to
appear with the character(s) from the specified set but not in any
particular place i.e. not necessarily at the beginning or end. For
example, I want the following to be valid:

dddd, d. MMMM yyyy
dddd, d. MMMM MyYear
MyDay, d. MMMM yyyy
dddd, d. MyMonth yyyy

so MyDay, MyYear and MyMonth appear in single quotes in the xml file
and are valid.
Mar 30 '07 #3
On 30 Mar, 14:30, ror...@gmail.co m wrote:
On Mar 30, 2:02 pm, Bjoern Hoehrmann <bjo...@hoehrma nn.dewrote:


* ror...@gmail.co m wrote in comp.text.xml:
>I have a regular expression that allows only certain characters to be
>valid in an xml doc as follows:
><xs:pattern value="^[ dgHhMmstyf,\-\./:;\\]*" />
>What I want to do is also allow any unicode character that is enclosed
>in single quotes to also be valid, no matter where they appear. I
>tried the following:
><xs:pattern value="^[ dgHhMmstyf,\-\./:;\\]*('*)*" />
>But this only works if the characters in quotes appear after the other
>text.
You are looking for "(a character from a certain set, or the character '
followed by zero or more characters except the character ' followed by
the character ') zero or more times", i.e. something like
([a-z]|'[^']*')*
if the first set of characters was a-z.
--
Björn Höhrmann · mailto:bjo...@h oehrmann.de ·http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 ·http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 ·http://www.websitedev.de/

Not quite - I want to allow the character(s) in quotes to be able to
appear with the character(s) from the specified set but not in any
particular place i.e. not necessarily at the beginning or end. For
example, I want the following to be valid:

dddd, d. MMMM yyyy
dddd, d. MMMM MyYear
MyDay, d. MMMM yyyy
dddd, d. MyMonth yyyy

so MyDay, MyYear and MyMonth appear in single quotes in the xml file
and are valid.- Hide quoted text -

- Show quoted text -
It looks to me that Björn's pattern achieves this. (Which filling in
the dots would be:

(^[ dgHhMmstyf,\-\./:;\\]|'[^']*')*

Can you do a test program and show some examples where it does not
work?

Cheers,

Pete.
--
=============== =============== ===============
Pete Cordell
Tech-Know-Ware Ltd
for XML to C++ data binding visit
http://www.tech-know-ware.com/lmx/
http://www.codalogic.com/lmx/
=============== =============== ===============

Apr 3 '07 #4
On Apr 3, 12:46 pm, use...@tech-know-ware.com wrote:
On 30 Mar, 14:30, ror...@gmail.co m wrote:


On Mar 30, 2:02 pm, Bjoern Hoehrmann <bjo...@hoehrma nn.dewrote:
* ror...@gmail.co m wrote in comp.text.xml:
I have a regular expression that allows only certain characters to be
valid in an xml doc as follows:
<xs:pattern value="^[ dgHhMmstyf,\-\./:;\\]*" />
What I want to do is also allow any unicode character that is enclosed
in single quotes to also be valid, no matter where they appear. I
tried the following:
<xs:pattern value="^[ dgHhMmstyf,\-\./:;\\]*('*)*" />
But this only works if the characters in quotes appear after the other
text.
You are looking for "(a character from a certain set, or the character '
followed by zero or more characters except the character ' followed by
the character ') zero or more times", i.e. something like
([a-z]|'[^']*')*
if the first set of characters was a-z.
--
Björn Höhrmann · mailto:bjo...@h oehrmann.de ·http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 ·http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 ·http://www.websitedev.de/
Not quite - I want to allow the character(s) in quotes to be able to
appear with the character(s) from the specified set but not in any
particular place i.e. not necessarily at the beginning or end. For
example, I want the following to be valid:
dddd, d. MMMM yyyy
dddd, d. MMMM MyYear
MyDay, d. MMMM yyyy
dddd, d. MyMonth yyyy
so MyDay, MyYear and MyMonth appear in single quotes in the xml file
and are valid.- Hide quoted text -
- Show quoted text -

It looks to me that Björn's pattern achieves this. (Which filling in
the dots would be:

(^[ dgHhMmstyf,\-\./:;\\]|'[^']*')*

Can you do a test program and show some examples where it does not
work?

Cheers,

Pete.
--
=============== =============== ===============
Pete Cordell
Tech-Know-Ware Ltd
for XML to C++ data binding visit
http://www.tech-know-ware.com/lmx/
http://www.codalogic.com/lmx/
=============== =============== ===============- Hide quoted text -

- Show quoted text -
The pipe(|) in you regular expression means 'or' right? If so then you
can only have the characters dgHhMmstyf,\-\./:;\\ OR characters in
quotes but not both in the same string so you can have:

dddd, d. MMMM yyyy
OR
'ab$olutN0n$en$ e'
But not

dddd, d. MMMM yyyy 'ab$olutN0n$en$ e'

Does this make sense?

Apr 4 '07 #5
On 4 Apr, 17:08, ror...@gmail.co m wrote:
On Apr 3, 12:46 pm, use...@tech-know-ware.com wrote:
....
It looks to me that Björn's pattern achieves this. (Which filling in
the dots would be:
(^[ dgHhMmstyf,\-\./:;\\]|'[^']*')*
Can you do a test program and show some examples where it does not
work?

The pipe(|) in you regular expression means 'or' right? If so then you
can only have the characters dgHhMmstyf,\-\./:;\\ OR characters in
quotes but not both in the same string so you can have:

dddd, d. MMMM yyyy
OR
'ab$olutN0n$en$ e'
But not

dddd, d. MMMM yyyy 'ab$olutN0n$en$ e'

Does this make sense?
But that's then wrapped in a set of brackets and a *. So you can have
any number of occurences of:

dddd, d. MMMM yyyy
OR
'ab$olutN0n$en$ e'

which means you can have:

dddd, d. MMMM yyyy 'ab$olutN0n$en$ e'

Note the pattern mentioned earlier is wrong. To match Bjorn's
suggestion it should not have had the first ^, so it becomes:

([ dgHhMmstyf,\-\./:;\\]|'[^']*')*

I recommend loading the pattern into whatever is the most convenient
regular expression parser for you such as Perl, PHP, Java, C#,
Javascript, and developing a number of test cases. Then check that
each one passes or fails as is appropriate. Then where there's
errors, list them here.

If you don't have a convenient regular expression engine locally you
might be able to download a pure regular expression tester, or do
something on the web such as: http://www.nvcc.edu/home/drodgers/ce...est_regexp.asp

BTW - when testing a regular expression destined for a schema on a
normal regular expression engine, remember to put ^ and $ anchors
around it.

HTH,

Pete.
--
=============== =============== ===============
Pete Cordell
Tech-Know-Ware Ltd
for XML to C++ data binding visit
http://www.tech-know-ware.com/lmx/
http://www.codalogic.com/lmx/
=============== =============== ===============

Apr 4 '07 #6
On Apr 4, 5:40 pm, use...@tech-know-ware.com wrote:
On 4 Apr, 17:08, ror...@gmail.co m wrote:


On Apr 3, 12:46 pm, use...@tech-know-ware.com wrote:

...
It looks to me that Björn's pattern achieves this. (Which filling in
the dots would be:
(^[ dgHhMmstyf,\-\./:;\\]|'[^']*')*
Can you do a test program and show some examples where it does not
work?
The pipe(|) in you regular expression means 'or' right? If so then you
can only have the characters dgHhMmstyf,\-\./:;\\ OR characters in
quotes but not both in the same string so you can have:
dddd, d. MMMM yyyy
OR
'ab$olutN0n$en$ e'
But not
dddd, d. MMMM yyyy 'ab$olutN0n$en$ e'
Does this make sense?

But that's then wrapped in a set of brackets and a *. So you can have
any number of occurences of:

dddd, d. MMMM yyyy
OR
'ab$olutN0n$en$ e'

which means you can have:

dddd, d. MMMM yyyy 'ab$olutN0n$en$ e'

Note the pattern mentioned earlier is wrong. To match Bjorn's
suggestion it should not have had the first ^, so it becomes:

([ dgHhMmstyf,\-\./:;\\]|'[^']*')*

I recommend loading the pattern into whatever is the most convenient
regular expression parser for you such as Perl, PHP, Java, C#,
Javascript, and developing a number of test cases. Then check that
each one passes or fails as is appropriate. Then where there's
errors, list them here.

If you don't have a convenient regular expression engine locally you
might be able to download a pure regular expression tester, or do
something on the web such as:http://www.nvcc.edu/home/drodgers/ce...est_regexp.asp

BTW - when testing a regular expression destined for a schema on a
normal regular expression engine, remember to put ^ and $ anchors
around it.

HTH,

Pete.
--
=============== =============== ===============
Pete Cordell
Tech-Know-Ware Ltd
for XML to C++ data binding visithttp://www.tech-know-ware.com/lmx/http://www.codalogic.c om/lmx/
=============== =============== ===============- Hide quoted text -

- Show quoted text -
I have it working now. Thanks a lot to all who replied.

-Rory.

Apr 5 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4182
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make regular expressions easier to create and use (and in my experience as a regular expression user, it makes them MUCH easier to create and use.) I'm still working on formal documentation, and in any case, such documentation isn't necessarily the...
4
5185
by: Együd Csaba | last post by:
Hi All, I'd like to "compress" the following two filter expressions into one - assuming that it makes sense regarding query execution performance. .... where (adate LIKE "2004.01.10 __:30" or adate LIKE "2004.01.10 __:15") .... into something like this: .... where adate LIKE "2004.01.10 __:(30/15)" ...
7
3829
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I want to avoid that. My question here is if there is a way to pass either a memory stream or array of "find", "replace" expressions or any other way to avoid multiple copies of a string. Any help will be highly appreciated
25
5166
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART (CONDUCTION DEFECT) 37.33/2 HEART (CONDUCTION DEFECT) WITH CATHETER 37.34/2 " the expression is "HEART (CONDUCTION DEFECT)". How do I gain access to the expression (not the matches) at runtime? Thanks, Mike
2
2015
by: comp.lang.php | last post by:
I am trying to replace within the HTML string $html the following: With Where I'm replacing "action=move_image" with "action=<?= $_REQUEST ?>"
1
4385
by: Allan Ebdrup | last post by:
I have a dynamic list of regular expressions, the expressions don't change very often but they can change. And I have a single string that I want to match the regular expressions against and find the first regular expression that matches the string. I've gor the regular expressions ordered so that the highest priority is first (if two or more regular expressions match the string I want the first one returned) The code that does this has...
4
1740
by: Brian Simmons | last post by:
Hi All, I've got a textbox where I want to make sure the person has entered at least 3 characters before submitting (it's like a partial name lookup type of query), so I don't want them to just enter "a" or "e" in the box and bring back everyone with an "a" or "e" in their name. I figure that a regular expression validation is the way to go, and I tried this: ValidationExpression="^({3,255})$"
8
1757
by: Nicodemas | last post by:
Hello all, could not find a regular expression forum, so I thought I would post it to my favorite of the forums. I have a series of applications I've developed which all use a centralized function that creates a connection object and executes an SQL query, i.e. function Query(). I always sanitize my SQL statements to buffer all apostrophes with two apostrophes ala function Buffer(). However, I have long wondered if I could do away with...
10
1687
by: Julien | last post by:
Hi, I'm fairly new in Python and I haven't used the regular expressions enough to be able to achieve what I want. I'd like to select terms in a string, so I can then do a search in my database. query = ' " some words" with and "without quotes " ' p = re.compile(magic_regular_expression) $ <--- the magic happens m = p.match(query)
0
9462
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10046
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9857
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8723
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7259
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6542
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3817
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2677
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.