473,811 Members | 3,008 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# equivalent statement for vb "Like" statement?

Is there a C# "Like" statement for comparing two strings?

if(stringA Like "%diabe%mel %)
do stuff...

Thanks in advance!

Derrick
Nov 16 '05 #1
4 7275
"Derrick" <de*********@ex cite.com> wrote in news:umhmc1aHEH A.3032
@TK2MSFTNGP09.p hx.gbl:
Is there a C# "Like" statement for comparing two strings?

if(stringA Like "%diabe%mel %)
do stuff...


the Regex class (in System.Text.Reg ularExpressions ) can do this for you.
For example:

Regex rgx = new Regex("diabe.*m el");
if (rgx.IsMatch(st ringA))
{
// Its a match
}

-mdb
Nov 16 '05 #2
Thanks, is it possible to have a regex to searches with "in any order" for
the params passed, in one call without creating all the possible word orders
as seperate regex'es?

With the below example, if a user types "diabe mel", find words that match,
basically, "%diab%mel% " as well as "%mel%diab% "

Thanks again for the help!

Derrick
"Michael Bray" <mb************ *******@SkPiAlM l.ctiusa.com> wrote in message
news:Xn******** *************** ***********@207 .46.248.16...
"Derrick" <de*********@ex cite.com> wrote in news:umhmc1aHEH A.3032
@TK2MSFTNGP09.p hx.gbl:
Is there a C# "Like" statement for comparing two strings?

if(stringA Like "%diabe%mel %)
do stuff...


the Regex class (in System.Text.Reg ularExpressions ) can do this for you.
For example:

Regex rgx = new Regex("diabe.*m el");
if (rgx.IsMatch(st ringA))
{
// Its a match
}

-mdb

Nov 16 '05 #3
"Derrick" <de*********@ex cite.com> wrote in
news:#6******** ******@TK2MSFTN GP12.phx.gbl:
Thanks, is it possible to have a regex to searches with "in any order"
for the params passed, in one call without creating all the possible
word orders as seperate regex'es?

With the below example, if a user types "diabe mel", find words that
match, basically, "%diab%mel% " as well as "%mel%diab% "


Sure... use the '|' operator, meaning this|that. So you could use the
regex "diab.*mel|mel. *diab"

-mdb
Nov 16 '05 #4
Hi Derrick
you can use String.Equals Method which determines whether two String
objects have the same value
string k;
string m;
if (m.equals(k))
you can read more on this link
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemstri ngclassequalsto pic.asp
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5607
by: Adam Short | last post by:
I've never needed it before but now I do! Does anyone know if you are able to perform a NOT Like search using Classic ASP ADO? i.e. myData.Filter = "Ref NOT LIKE '*1234*'" by the way this doesn't work!! and neither does myData.Filter = "Ref <> LIKE '*1234*'"
9
4636
by: Peter | last post by:
My problem is the last bit of coding below, the like statement does not work. what I have is a product options field and in it is stored characters i.e. "avcy" etc what the query does is that if I type in any single character all the products that match the criteria should be displayed. So if I typed in an "a" I should get 3 returns (see below) Fields could look like this: product.options: bhw djhsa
5
4382
by: TD | last post by:
I created a query in Access 2000 that runs perfectly. I then copied the "sql" version of the same query and set it equal the variable "sql" in the code below. When I run the code below I get an "Type Mismatch" error. Can someone explain how to fix this? Thanks, TD Private Sub cmdSave_Click()
2
5150
by: Big John | last post by:
in Access 2003 I am trying to get sql query to run using a field as input, but I want to input into the field a value that uses the "like" operator to find any value that starts with the value placed in the field. e.g if i place the text "ada" in the field i want all values with "ada???????" when the sql is run. I can do it in a query by placing the value in a like statement and it gives all variations , but i want the value to be a...
3
592
by: Derrick | last post by:
Is there a C# "Like" statement for comparing two strings? if(stringA Like "%diabe%mel%) do stuff... Thanks in advance! Derrick
1
19856
by: Craig Kenisston | last post by:
Hi, I need to write a function that should behave like the SQL's "like" operator on a list of words. I was wondering if I can use Regex directly to do this job. But I've been reading about regex and it supports very different characters and behaves different. So, I'm looking for an advise. I'd like to know if it is feasable or not, I mean, if dotnet Regex implementation could handle it.
9
2449
by: Drum2001 | last post by:
Hello All! I am using the following code during an On Click event for a button. It works properly to create a query for a report: Private Sub Command14_Click() If IsNull(Me.Text30) Then ' No criteria here - so ignore Else strWhere = strWhere & ",'" & Me.Text30.Value & "'"
1
1564
by: unamas | last post by:
hi, Good day! Anyone generous enough to help me with this query. Anyway, I have a random acount number of 1, 2, 3, 4, 5 and i wanna get the results after this number in a table. Select * from table where account like ('1%','2%', '3%','4%','5%')
0
10393
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10405
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10136
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5556
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5697
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3871
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3020
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.