Training, Open Source computer languages

PerlPythonMySQLTclRubyC & C++LuaJavaTomcatPHPhttpdLinux

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Regular expression for 6 digits OR 25 digits

I can write a regular expression to match ANY number of digits between 6 and 25 ...

^[[:digit:]]{6,25}$

but how would I write a regular expression to match either 6 digits or 25 digits, but no number in between?

^([[:digit:]]{6}|[[:digit:]]{25})$

(The regular expressions in this example are Tcl and PHP/ereg types. use \d instead of [[:digit:]] for PHP/preg and Perl.)


You may wonder why I want this. A client with 6 digit or 25 digit part numbers, a year number that can be 2 or 4 digits ...
(written 2008-04-16 19:06:00)

 
Associated topics are indexed under
Q803 - Object Orientation and General technical topics - Regular Expressions - Extra Elements
H107 - String Handling in PHP
T247 - Tcl/Tk - Advanced Regular Expressions

Back to
Comfy Chair - Floating Harbour, Bristol
Previous and next
or
Horse's mouth home
Forward to
When an array is not an array
Some other Articles
Steam Engines at Bressingham
Not daring to be an anorak
PHP training courses every month
When an array is not an array
Regular expression for 6 digits OR 25 digits
Comfy Chair - Floating Harbour, Bristol
Gauging point at entrance to Bristols Floating Harbour
PHP course dot co, dot uk
Chew Valley Lakes
Underlining in Perl and Python - the x and * operator in use
1816 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

© WELL HOUSE CONSULTANTS LTD., 2008: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 0800 043 8225 or 01225 708225 • FAX: 0845 8382 405 or 01225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho