Using PHP eregi Function - Solve XML XSD Pattern Definition

  • Context: PHP 
  • Thread starter Thread starter Hootenanny
  • Start date Start date
  • Tags Tags
    Function Php
Click For Summary
SUMMARY

The discussion focuses on converting an XML XSD pattern definition into a PHP ereg regular expression for validating UK driving license numbers. The original pattern provided is: [A-Z,0-9]{5}[0-9][0,1,5,6][0-9]([0][1-9]|[1-2][0-9]|[3][0,1])[0-9][A-Z,0-9]{3}[A-Z]{2}. The user successfully tested the regex by adding slashes, confirming its functionality for the intended validation purpose. The solution highlights the importance of proper syntax in regex for effective pattern matching.

PREREQUISITES
  • Understanding of regular expressions (regex) syntax
  • Familiarity with PHP programming language
  • Knowledge of XML XSD pattern definitions
  • Experience with form validation techniques
NEXT STEPS
  • Learn PHP preg_match function for regex validation
  • Explore advanced regex features in PHP
  • Study XML Schema Definition (XSD) for data validation
  • Investigate best practices for form input validation
USEFUL FOR

Web developers, PHP programmers, and anyone involved in form validation and data integrity checks, particularly those working with XML and regex patterns.

Hootenanny
Staff Emeritus
Science Advisor
Gold Member
Messages
9,621
Reaction score
9
Hi all,

I have this xml xsd pattern defintion;

Code:
[A-Z,0-9]{5}[0-9][0,1,5,6][0-9]([0][1-9]|[1-2][0-9]|[3][0,1])[0-9][A-Z,0-9]{3}[A-Z]{2}

and I need to convert it into an ereg regular expression to valid some input from a form. I've been at this for hours but can't seem to get anywhere. Can any of you guys help out...?
 
Technology news on Phys.org
This is an extended "legal" regex:
Code:
/[A-Z,0-9]{5}[0-9][0,1,5,6][0-9]\([0][1-9]|[1-2][0-9]|[3][0,1]\)[0-9][A-Z,0-9]{3}[A-Z]{2}/

But I have no way of knowing if it works or even finds what you need. I added /'s to test the grammar
 
jim mcnamara said:
This is an extended "legal" regex:
Code:
/[A-Z,0-9]{5}[0-9][0,1,5,6][0-9]\([0][1-9]|[1-2][0-9]|[3][0,1]\)[0-9][A-Z,0-9]{3}[A-Z]{2}/

But I have no way of knowing if it works or even finds what you need. I added /'s to test the grammar
The slashes worked Jim, thanks a lot! FYI I'm using the regex to verify UK driving license numbers. Thanks again.
 

Similar threads

  • · Replies 17 ·
Replies
17
Views
4K
  • · Replies 7 ·
Replies
7
Views
6K
Replies
12
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 4 ·
Replies
4
Views
7K
Replies
6
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K