In the old Visual Basic I could do something like this
myCheck = "aBBBa" Like "a*a"
The return value would be true. Is there a way for comparing strings in C#
were I can use wild characters like * etc? 7 1372
"Rene" <no****@nospam.com> wrote in
news:u7**************@TK2MSFTNGP11.phx.gbl: In the old Visual Basic I could do something like this
myCheck = "aBBBa" Like "a*a"
The return value would be true. Is there a way for comparing strings in C# were I can use wild characters like * etc?
The .Net framework provides regular expressions:
using System.Text.RegularExpressions;
...
bool myCheck = Regex.IsMatch("aBBBa", "^a.*a$");
Hope this helps.
Chris.
-------------
C.R. Timmons Consulting, Inc. http://www.crtimmonsinc.com/
Your pattern string has a "^" a "." a "*" and a "$". Could you please tell
me what all this symbols are for? I recognize the reason for the "*" but I
have no idea what the others are there for! I didn't find this info in the
documentation.
Thank you.
"Chris R. Timmons" <crtimmons@X_NOSPAM_Xcrtimmonsinc.com> wrote in message
news:Xn*********************************@207.46.24 8.16... "Rene" <no****@nospam.com> wrote in news:u7**************@TK2MSFTNGP11.phx.gbl:
In the old Visual Basic I could do something like this
myCheck = "aBBBa" Like "a*a"
The return value would be true. Is there a way for comparing strings in C# were I can use wild characters like * etc?
The .Net framework provides regular expressions:
using System.Text.RegularExpressions; ... bool myCheck = Regex.IsMatch("aBBBa", "^a.*a$");
Hope this helps.
Chris. ------------- C.R. Timmons Consulting, Inc. http://www.crtimmonsinc.com/
"^" means the beginning of the string. If you left this out, it would match
things like XYZaBBBa
"." means any character and ".*" means any number (zero or more) of any
character
"$" means the end of the string. If you left this out, it would match things
like aBBBaXYZ
"Rene" <no****@nospam.com> wrote in message
news:ej*************@tk2msftngp13.phx.gbl... Your pattern string has a "^" a "." a "*" and a "$". Could you please tell me what all this symbols are for? I recognize the reason for the "*" but I have no idea what the others are there for! I didn't find this info in the documentation.
Thank you.
"Chris R. Timmons" <crtimmons@X_NOSPAM_Xcrtimmonsinc.com> wrote in message news:Xn*********************************@207.46.24 8.16... "Rene" <no****@nospam.com> wrote in news:u7**************@TK2MSFTNGP11.phx.gbl:
In the old Visual Basic I could do something like this
myCheck = "aBBBa" Like "a*a"
The return value would be true. Is there a way for comparing strings in C# were I can use wild characters like * etc?
The .Net framework provides regular expressions:
using System.Text.RegularExpressions; ... bool myCheck = Regex.IsMatch("aBBBa", "^a.*a$");
Hope this helps.
Chris. ------------- C.R. Timmons Consulting, Inc. http://www.crtimmonsinc.com/
Thank you, that really helped.
Could you please tell me where can I find this information (web link or
something similar) so that I can take a closer look and see what else I can
learn about comparing string?
Thank you.
"Bret Mulvey" <br***@microsoft.nospam0000.com> wrote in message
news:1Uvdb.611823$uu5.99847@sccrnsc04... "^" means the beginning of the string. If you left this out, it would
match things like XYZaBBBa
"." means any character and ".*" means any number (zero or more) of any character
"$" means the end of the string. If you left this out, it would match
things like aBBBaXYZ
"Rene" <no****@nospam.com> wrote in message news:ej*************@tk2msftngp13.phx.gbl... Your pattern string has a "^" a "." a "*" and a "$". Could you please
tell me what all this symbols are for? I recognize the reason for the "*" but
I have no idea what the others are there for! I didn't find this info in
the documentation.
Thank you.
"Chris R. Timmons" <crtimmons@X_NOSPAM_Xcrtimmonsinc.com> wrote in
message news:Xn*********************************@207.46.24 8.16... "Rene" <no****@nospam.com> wrote in news:u7**************@TK2MSFTNGP11.phx.gbl:
> In the old Visual Basic I could do something like this > > myCheck = "aBBBa" Like "a*a" > > The return value would be true. Is there a way for comparing > strings in C# were I can use wild characters like * etc?
The .Net framework provides regular expressions:
using System.Text.RegularExpressions; ... bool myCheck = Regex.IsMatch("aBBBa", "^a.*a$");
Hope this helps.
Chris. ------------- C.R. Timmons Consulting, Inc. http://www.crtimmonsinc.com/
Rene <no****@nospam.com> wrote: Thank you, that really helped.
Could you please tell me where can I find this information (web link or something similar) so that I can take a closer look and see what else I can learn about comparing string?
Look up "regular expressions" in the MSDN, and you should find a lot of
information.
--
Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Rene wrote: Your pattern string has a "^" a "." a "*" and a "$". Could you please tell me what all this symbols are for? I recognize the reason for the "*" but I have no idea what the others are there for! I didn't find this info in the documentation.
Look for "regular expressions" in the index of the .NET docs. You'll find
a huge range of topics about it.
--
Rudy Velthuis
"Before C++ we had to code all of our bugs by hand; now we inherit
them." -- unknown
MSDN has documentatioin for this at http://msdn.microsoft.com/library/en...ularexpression
slanguageelements.asp
"Rene" <no****@nospam.com> wrote in message
news:eR**************@TK2MSFTNGP12.phx.gbl... Thank you, that really helped.
Could you please tell me where can I find this information (web link or something similar) so that I can take a closer look and see what else I
can learn about comparing string?
Thank you. "Bret Mulvey" <br***@microsoft.nospam0000.com> wrote in message news:1Uvdb.611823$uu5.99847@sccrnsc04... "^" means the beginning of the string. If you left this out, it would match things like XYZaBBBa
"." means any character and ".*" means any number (zero or more) of any character
"$" means the end of the string. If you left this out, it would match things like aBBBaXYZ
"Rene" <no****@nospam.com> wrote in message news:ej*************@tk2msftngp13.phx.gbl... Your pattern string has a "^" a "." a "*" and a "$". Could you please tell me what all this symbols are for? I recognize the reason for the "*"
but I have no idea what the others are there for! I didn't find this info in the documentation.
Thank you.
"Chris R. Timmons" <crtimmons@X_NOSPAM_Xcrtimmonsinc.com> wrote in message news:Xn*********************************@207.46.24 8.16... > "Rene" <no****@nospam.com> wrote in > news:u7**************@TK2MSFTNGP11.phx.gbl: > > > In the old Visual Basic I could do something like this > > > > myCheck = "aBBBa" Like "a*a" > > > > The return value would be true. Is there a way for comparing > > strings in C# were I can use wild characters like * etc? > > The .Net framework provides regular expressions: > > > using System.Text.RegularExpressions; > ... > bool myCheck = Regex.IsMatch("aBBBa", "^a.*a$"); > > > Hope this helps. > > Chris. > ------------- > C.R. Timmons Consulting, Inc. > http://www.crtimmonsinc.com/
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Arvid Andersson |
last post by:
Hello, I need to convert a string to a number, but the string can
contain +,-,* and / as well as parenthesis. For example, if I have the
string "30/(6+9)" I would like a function that returned the...
|
by: Jason Heyes |
last post by:
I wrote a previous post that asked whether there was a reference-counted
implementation of std::vector. Apparantly there wasn't. So my next question
is, is it possible to write your own shared...
|
by: Jason |
last post by:
Hello. I am trying to learn how operator overloading works so I wrote
a simple class to help me practice. I understand the basic opertoar
overload like + - / *, but when I try to overload more...
|
by: Markus Dehmann |
last post by:
I have a two different value types with which I want to do similar
things: store them in the same vector, stack, etc. Also, I want an <<
operator for each of them.
class Value{}; // this would...
|
by: Rich Herrick |
last post by:
The latest version of my "Pascal-like" set class is available here:
http://www.richherrick.com/software/herrick-1.0.zip
Those from the old YAHOO BOOST forum might remember it from several...
|
by: Ed Brown |
last post by:
I'm working on a VB.Net application that needs to do quite a bit of string
pattern matching, and am having problems using the "LIKE" operator to match
the same string twice in the pattern. For...
|
by: ex_ottoyuhr |
last post by:
I have a situation more or less as follows, and it's causing me no end
of trouble; I'd appreciate anyone's advice on the matter...
Given these classes:
class BedrockCitizen { ... };
class...
|
by: Piotr Sawuk |
last post by:
What is wrong with the following? Why doesn't it compile?
template<int f, class me, typename ValType=int>
class Fm
{
protected:
ValType v;
public:
me& operator+=(const me& o)...
|
by: Christian Schmidt |
last post by:
Hi all,
I'm trying to implement a std::vector-like wrapper for IList.
The hard part seems to be operator, because it returns an unmanaged
reference. Probably I have to use pin_ptr to achieve this,...
|
by: simudream |
last post by:
//hi maybe helpful others can look at this code and
//tell me why the class code won't behave like
//intrinsic types with post and pre increment
//Version: 1.00
#include <iostream>
using...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
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: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
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...
| |