Should not the following return False if s="255xxxxyyy"? It seems to return
True.
Regex.IsMatch(s, "[0-9]")
--
Dennis in Houston 5 2245
Yes, it should return false.
'-- Check for number
Regex.IsMatch(s, "^\d+$")
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:4E**********************************@microsof t.com... Should not the following return False if s="255xxxxyyy"? It seems to return True.
Regex.IsMatch(s, "[0-9]") -- Dennis in Houston
?Thanks for reply. Which one should return false, the one you send
(Regex.IsMatch(s, "^\d+$") or mine (Regex.IsMatch(s, "[0-9]")? Mine returns
true in VB.net 2003.
"Dr Screwup" wrote: Yes, it should return false.
'-- Check for number Regex.IsMatch(s, "^\d+$")
"Dennis" <De****@discussions.microsoft.com> wrote in message news:4E**********************************@microsof t.com... Should not the following return False if s="255xxxxyyy"? It seems to return True.
Regex.IsMatch(s, "[0-9]") -- Dennis in Houston
Mine should be true for this: s = "1293" and false for this s= "255xxxxyyy.
Yours will return true for anything except this s="ABC" (anything without a
number).
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com... ?Thanks for reply. Which one should return false, the one you send (Regex.IsMatch(s, "^\d+$") or mine (Regex.IsMatch(s, "[0-9]")? Mine returns true in VB.net 2003.
"Dr Screwup" wrote:
Yes, it should return false.
'-- Check for number Regex.IsMatch(s, "^\d+$")
"Dennis" <De****@discussions.microsoft.com> wrote in message news:4E**********************************@microsof t.com... > Should not the following return False if s="255xxxxyyy"? It seems to > return > True. > > Regex.IsMatch(s, "[0-9]") > -- > Dennis in Houston
Thanks. I guess I really had it wrong. I got the Regex string from one of
the previous notes on this newsgroup.
"Dr Screwup" wrote: Mine should be true for this: s = "1293" and false for this s= "255xxxxyyy. Yours will return true for anything except this s="ABC" (anything without a number).
"Dennis" <De****@discussions.microsoft.com> wrote in message news:0A**********************************@microsof t.com... ?Thanks for reply. Which one should return false, the one you send (Regex.IsMatch(s, "^\d+$") or mine (Regex.IsMatch(s, "[0-9]")? Mine returns true in VB.net 2003.
"Dr Screwup" wrote:
Yes, it should return false.
'-- Check for number Regex.IsMatch(s, "^\d+$")
"Dennis" <De****@discussions.microsoft.com> wrote in message news:4E**********************************@microsof t.com... > Should not the following return False if s="255xxxxyyy"? It seems to > return > True. > > Regex.IsMatch(s, "[0-9]") > -- > Dennis in Houston
Dennis, Should not the following return False if s="255xxxxyyy"? It seems to return True.
Regex.IsMatch(s, "[0-9]")
If you try it, you will find it returns True, as you are looking for a
single digit 0 thru 9 anyplace in the input string. The string "255xxxxyyy"
contains 3 matches, the first 2, the first 5 & the second 5.
While: Regex.IsMatch(s, "^\d+$")
Will return false for "255xxxxyyy", as you are looking for the beginning of
the string "^", followed by one or more digits "\d+", followed by the end of
the string "$".
For example, try the following code for both patterns:
Imports System.Text.RegularExpressions
Const theFirstPattern As String = "[0-9]"
Const theSecondPattern As String = "^\d+$"
Const input As String = "255xxxxyyy"
Dim theFirstRegex As New Regex(theFirstPattern)
Debug.WriteLine(theFirstRegex.IsMatch(input), "first is match")
For Each aMatch As Match In theFirstRegex.Matches(input)
Debug.WriteLine(aMatch.Value, aMatch.Index.ToString())
Next
Dim theSecondRegex As New Regex(theSecondPattern)
Debug.WriteLine(theSecondRegex.IsMatch(input), "second is match")
For Each aMatch As Match In theSecondRegex.Matches(input)
Debug.WriteLine(aMatch.Value, aMatch.Index.ToString())
Next
The following site provides a good overview of regular expressions: http://www.regular-expressions.info/
While this site provides the syntax specifically supported by .NET: http://msdn.microsoft.com/library/de...geElements.asp
Hope this helps
Jay
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:4E**********************************@microsof t.com... Should not the following return False if s="255xxxxyyy"? It seems to return True.
Regex.IsMatch(s, "[0-9]") -- Dennis in Houston This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Christ |
last post by:
Hi there,
i'm trying to make a regex, but it ain't working.
In just one regex expression I want to check a password that must meet
following requirements:
- at least 6 characters long
- at...
|
by: Johnny |
last post by:
I need to determine whether a text box contains a value that does not convert
to a decimal. If the value does not convert to a decimal, I want to throw a
MessageBox to have the user correct the...
|
by: aevans1108 |
last post by:
expanding this message to microsoft.public.dotnet.xml
Greetings
Please direct me to the right group if this is an inappropriate place
to post this question. Thanks.
I want to format a...
|
by: Tim Conner |
last post by:
Is there a way to write a faster function ?
public static bool IsNumber( char Value )
{
if (Regex.IsMatch( Value.ToString(), @"^+$" ))
{
return true;
}
else return false;
}
|
by: vbmark |
last post by:
I'm new to RegEx in vb.net so I'm not sure how to do this.
I want to know if a string contains two minus signs "-". If there are two
then I want it to return TRUE.
I also need to know if the...
|
by: jg |
last post by:
I made a mistake somewhere in my vb code and I look, check and read against
the articles and help on regex, I still can't find the mistake I made.
I know my test string and the test patterns...
|
by: cassetti |
last post by:
Here's the issue:
I have roughly 20 MS excel spreadsheets, each row contains a record.
These records were hand entered by people in call centers.
The problem is, there can and are duplicate...
|
by: MattMika |
last post by:
Can anyone point out the problem with this? The commented regex var
and if statement dont work and break the GroupName check when
uncommented. I tested the AccessCodeRegxp with preg_match and it...
|
by: TumurS |
last post by:
Hi!
I need to parse an input string. The string must consist of 1, 2 or 3 float
numbers
separated with blanks:
Regex r = new
Regex(@"^\s*(?<x>+)(\s+(?<y>+)(\s+(?<z>+))*)*\s*$",...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |