473,387 Members | 1,493 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,387 software developers and data experts.

string function that finds substring within string

Is there some function that will return a boolean if a certain substring is
inside another string(eg. Is "name" inside 'My name is")? And if it finds
the substring, will it tell me in what position?

Thanks.
Nov 15 '05 #1
4 3725
hi vaughn,

string MyString = "My name is";
int pos = MyString.IndexOf("name");

if "name" not found, pos will be -1 else the actual index.

regards,
--
gani
pls visit http://thedeveloperscorner.com.ph

"vaughn" <VM> wrote in message news:OF**************@TK2MSFTNGP12.phx.gbl...
Is there some function that will return a boolean if a certain substring is inside another string(eg. Is "name" inside 'My name is")? And if it finds
the substring, will it tell me in what position?

Thanks.

Nov 15 '05 #2
hi vaughn,

string MyString = "My name is";
int pos = MyString.IndexOf("name");

if "name" not found, pos will be -1 else the actual index.

regards,
--
gani
pls visit http://thedeveloperscorner.com.ph

"vaughn" <VM> wrote in message news:OF**************@TK2MSFTNGP12.phx.gbl...
Is there some function that will return a boolean if a certain substring is inside another string(eg. Is "name" inside 'My name is")? And if it finds
the substring, will it tell me in what position?

Thanks.

Nov 15 '05 #3
"vaughn" <VM> wrote in message news:OF**************@TK2MSFTNGP12.phx.gbl...
Is there some function that will return a boolean if a certain substring is inside another string(eg. Is "name" inside 'My name is")? And if it finds
the substring, will it tell me in what position?

Thanks.
string test = "abcDEF";

if (test.LastIndexOf("DEF") > -1)
{
....
}

--
compatible web farm Session replacement for Asp and Asp.Net
http://www.nieropwebconsult.nl/asp_session_manager.htm



Nov 15 '05 #4
"vaughn" <VM> wrote in message news:OF**************@TK2MSFTNGP12.phx.gbl...
Is there some function that will return a boolean if a certain substring is inside another string(eg. Is "name" inside 'My name is")? And if it finds
the substring, will it tell me in what position?

Thanks.
string test = "abcDEF";

if (test.LastIndexOf("DEF") > -1)
{
....
}

--
compatible web farm Session replacement for Asp and Asp.Net
http://www.nieropwebconsult.nl/asp_session_manager.htm



Nov 15 '05 #5

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

Similar topics

6
by: becte | last post by:
I am little bit confused Is this a legal way of removing a substring from a string? What about the second alternative using strcpy, is it ok even though the source and dest. strings overlap? ...
0
by: vaughn | last post by:
Is there some function that will return a boolean if a certain substring is inside another string(eg. Is "name" inside 'My name is")? And if it finds the substring, will it tell me in what...
29
by: zoro | last post by:
Hi, I am new to C#, coming from Delphi. In Delphi, I am using a 3rd party string handling library that includes some very useful string functions, in particular I'm interested in BEFORE (return...
2
by: Trint Smith | last post by:
Ok, My program has been formating .txt files for input into sql server and ran into a problem...the .txt is an export from an accounting package and is only supposed to contain comas (,) between...
2
by: Badass Scotsman | last post by:
Hello, Using VB and ASP,NET I would like to be able to search a STRING for a smaller STRING within, based on the characters which appear before and after. For example: String1 = " That was...
6
by: kellygreer1 | last post by:
What is a good one line method for doing a "length safe" String.Substring? The VB classes offer up the old Left function so that string s = Microsoft.VisualBasic.Left("kelly",200) // s will =...
1
by: kellysgirl | last post by:
Now what you are going to see posted here is both the set of instructions I was given..and the code I have written. The instructions I was given are as follows In this case, you will create...
8
by: thunderbolt | last post by:
Hi, How do i parse a string "ABC 2005 (12)" and convert it to "ABC 2005 (Dec)" in C#? The number within the brackets represent month.. am new to c# and breaking head for couple of hours over...
12
by: kevineller794 | last post by:
I want to make a split string function, but it's getting complicated. What I want to do is make a function with a String, BeginStr and an EndStr variable, and I want it to return it in a char...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.