Regex Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreRegex Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 11th, 2009, 06:44 PM
latros latros is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 233 latros User rank is Second Lieutenant (5000 - 10000 Reputation Level)latros User rank is Second Lieutenant (5000 - 10000 Reputation Level)latros User rank is Second Lieutenant (5000 - 10000 Reputation Level)latros User rank is Second Lieutenant (5000 - 10000 Reputation Level)latros User rank is Second Lieutenant (5000 - 10000 Reputation Level)latros User rank is Second Lieutenant (5000 - 10000 Reputation Level)latros User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 16 h 38 m 21 sec
Reputation Power: 75
A regex for two numbers separated by a space or comma

Hi, i would like to create a regex match for X Y coordinates.

X and Y can be positive or negative; decimal or integer.

They are separated by a space, comma, or tab.

This is what I have (code below), and it works, BUT the problem is that it allows more than two numbers.

For instance, 1,1 works, which is good, but 1,1,1,1,1,1 also works, which is bad.

I have the \b (boundary) tags on each side to signify the start and end of the string, but I guess its not working.

By the way, the programming language is VB.NET if that makes any difference. If you can help me, I will be most appreciative.

My code:
Code:
Dim strRegEx As String = "\b(-{0,1}\d*\.{0,1}\d+)[, \t](-{0,1}\d*\.{0,1}\d+)\b"

Reply With Quote
  #2  
Old May 11th, 2009, 07:15 PM
OmegaZero OmegaZero is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2007
Posts: 737 OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level)OmegaZero User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 13 m 32 sec
Reputation Power: 928
\b matches the beginning or end of words. ^ and $ match the beginning and end of the string (respectively).

Incidentally, ? has the same meaning as {0,1} and is a bit easier to read.
__________________
sub{*{$::{$_}}{CODE}==$_[0]&& print for(%:: )}->(\&Meh);

Reply With Quote
  #3  
Old May 11th, 2009, 07:58 PM
latros latros is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 233 latros User rank is Second Lieutenant (5000 - 10000 Reputation Level)latros User rank is Second Lieutenant (5000 - 10000 Reputation Level)latros User rank is Second Lieutenant (5000 - 10000 Reputation Level)latros User rank is Second Lieutenant (5000 - 10000 Reputation Level)latros User rank is Second Lieutenant (5000 - 10000 Reputation Level)latros User rank is Second Lieutenant (5000 - 10000 Reputation Level)latros User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 16 h 38 m 21 sec
Reputation Power: 75
perfect! Thanks!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreRegex Programming > A regex for two numbers separated by a space or comma

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap