|
-
Feb 18th, 2010, 10:01 AM
#1
[RESOLVED] Need help with a simple regex pattern
I need a pattern for an asp.net validator that's for a phone extension field on the entry part of the page. I need it to allow a single digit up to 5 digits. I was able to use this pattern "\d{5}?" until the requirements changed to "up to 5 digits" on me
Anyone care to help with this?
-
Feb 18th, 2010, 10:11 AM
#2
Re: Need help with a simple regex pattern
not sure but something like this?
\[0-9]{5}
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Feb 18th, 2010, 10:38 AM
#3
Re: Need help with a simple regex pattern
-
Feb 18th, 2010, 10:38 AM
#4
Fanatic Member
Re: [RESOLVED] Need help with a simple regex pattern
You don't backslash [0-9].
Also, \d and [0-9] are the same thing.
What does the string look like that you will be searching.
Might be easier to help.
I'm not aware of a way to determine a variable amount of letters other than \d+.
However, it depends on what is around that number that can help determine a possible bound for stopping the search for a number.
Last edited by Seraph; Feb 18th, 2010 at 10:42 AM.
Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7
SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
[Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]
[.NET and MySQL Quick Guide]
-
Feb 18th, 2010, 10:42 AM
#5
Re: [RESOLVED] Need help with a simple regex pattern
{5} is for max 5
{0,5} is for a minimum of 1 and a maximum of 5. You didn't mention any thing about minimum?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Feb 18th, 2010, 10:43 AM
#6
Fanatic Member
Re: [RESOLVED] Need help with a simple regex pattern
ahh, ok..that's cool good to know there's a variable amount you can search for.
He said "up to 5"...that sounds variable to me. lol
Visual Studio 2010 Professional | .NET Framework 4.0 | Windows 7
SERYSOFT.COM :: SysPad - Folder Management Program - Please comment HERE if you find this program useful, have ideas, or know of any bugs.
[Very useful for IT/DP departments where many folders are consistently accessed. Also contains a scratchpad window for quick access to notes.]
[.NET and MySQL Quick Guide]
-
Feb 18th, 2010, 11:44 AM
#7
Re: [RESOLVED] Need help with a simple regex pattern
Sorry guys, I guess I posted using too much common sense. I figured that given I said it's for a phone number extension field and it's required to be "up to 5" you guys, as programmers, would know the range is 0 to 5 digits. Each digit being a number >= 0 and <= 9.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|