LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
mp mp is offline
external usenet poster
 
Posts: 70
Default regex validate rangename

any regex experts here?
trying to validate a string passed in to see if it refers to a valid excel
range name
"a1" or "A1" to "iv65536" or "IV65536"

this clearly isn't it, i'm a regex dunce!
Regex regex = new Regex("[a-zA-Z][a-iA-I][a-vA-V][1-65536]");
this is no good either
Regex regex = new Regex("[a-zA-Zaa-ivAA-IV][1-65536]");

bool b;
b = regex.IsMatch("x1");
Debug.Print(b.ToString());//true

b = regex.IsMatch("1a");
Debug.Print(b.ToString());//false

b = regex.IsMatch("AC65536");
Debug.Print(b.ToString());//true

b = regex.IsMatch("IV65537");
Debug.Print(b.ToString());//false

b = regex.IsMatch("IV65536");
Debug.Print(b.ToString());//true

any tips appreciated
i suppose i could parse the incoming string and separate the alpha and
numeric parts
but with regex that shouldn't be necessary, right?
thanks
mark


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Testing For a RangeName JCS Excel Discussion (Misc queries) 3 August 13th 08 01:08 PM
Confused with RangeName CellREfs Jim May Excel Discussion (Misc queries) 1 October 22nd 06 11:11 PM
union of RangeName Bob Phillips Excel Programming 1 October 20th 06 12:35 PM
Concatenate RangeName for INDEX? CLR Excel Worksheet Functions 5 November 30th 04 07:47 PM
Validate Excel Range with RegEx Fletch[_2_] Excel Programming 1 December 8th 03 03:22 PM


All times are GMT +1. The time now is 06:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"