473,394 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

string compare

how can I know does some string contain some chars?

Now I use
Text1.StartsWith("nah")

I need something like SQL code "text1 like('%nah%')"
Nov 16 '05 #1
5 1260

"Dino L." <se******@gmail.com> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...
how can I know does some string contain some chars?

Now I use
Text1.StartsWith("nah")

I need something like SQL code "text1 like('%nah%')"


Have a look at the IndexOf() method in the String class.

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Nov 16 '05 #2

"Dino L." <se******@gmail.com> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...
how can I know does some string contain some chars?

Now I use
Text1.StartsWith("nah")

I need something like SQL code "text1 like('%nah%')"


Have a look at the IndexOf() method in the String class.

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Nov 16 '05 #3
try
if(Text1.IndexOf("nah") != -1)
{
....
}

--
-Philip Rieck
http://philiprieck.com/blog/

-
"Dino L." <se******@gmail.com> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...
how can I know does some string contain some chars?

Now I use
Text1.StartsWith("nah")

I need something like SQL code "text1 like('%nah%')"

Nov 16 '05 #4
try
if(Text1.IndexOf("nah") != -1)
{
....
}

--
-Philip Rieck
http://philiprieck.com/blog/

-
"Dino L." <se******@gmail.com> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...
how can I know does some string contain some chars?

Now I use
Text1.StartsWith("nah")

I need something like SQL code "text1 like('%nah%')"

Nov 16 '05 #5
Hi,

You can use IndexOf or LastIndexOf from String class

If it's a more complex expression you can use a regular expression, take a
look at Regex class and IsMatch method
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Dino L." <se******@gmail.com> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...
how can I know does some string contain some chars?

Now I use
Text1.StartsWith("nah")

I need something like SQL code "text1 like('%nah%')"

Nov 16 '05 #6

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

Similar topics

13
by: usgog | last post by:
I need to implement a function to return True/false whether String A contains String B. For example, String A = "This is a test"; String B = "is is". So it will return TRUE if String A includes two...
32
by: Wolfgang Draxinger | last post by:
I understand that it is perfectly possible to store UTF-8 strings in a std::string, however doing so can cause some implicaions. E.g. you can't count the amount of characters by length() | size()....
19
by: David zhu | last post by:
I've got different result when comparing two strings using "==" and string.Compare(). The two strings seems to have same value "1202002" in the quick watch, and both have the same length 7 which I...
6
by: Maileen | last post by:
Hi, I have the following code : Function GetRequestType(ByVal EvDt As String, ByVal StPeriod As String, ByVal EdPeriod As String, ByVal TaskType As String) As Integer Dim strtest As String Dim...
10
by: lchian | last post by:
Hi, For two stl strings s1 and s2, I got different results from strcmp(s1.c_str(), s2.c_str()) and s1.compare(s2) can someone explain what these functions do? It seems that strcmp gives...
14
by: Mosfet | last post by:
Hi, what is the most efficient way of doing a case insensitive comparison ? I am trying to write a universal String class and I am stuck with the case insensitive part : TCHAR is a char in...
11
by: Tony | last post by:
Hello! Below I have two different ways to test if the instance tb.Text contains the string "Programmer" So which one to use is it just a matter of taste ? Or could it be some advantage to one...
11
by: blunt | last post by:
trying to write a program to write the configuration files for a load of wireless access points. i've never been a good programmer and haven't done any for nearly a decade so have obviously made some...
1
by: blunt | last post by:
trying to write a program to write the configuration files for a load of wireless access points. i've never been a good programmer and haven't done any for nearly a decade so have obviously made some...
5
by: erictheone | last post by:
so here is my code. My getlines for the strings keyword and phrase at lines 44 and 79 respectively don't work. Please help!!! #include <cstdlib> #include <string> #include <iostream> #include...
0
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...
0
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...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
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...
0
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...

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.