Hi !!
I have to find some words in a string.
I can use string.IndexOf, LastIndexOf, etc, but they are case
sensitive.
And there is another problem : If I found the word, I have to get
three words before and after the found word .
Example:
string s = "This is an example about how to find words in a string";
string wordToFind = "Example"
I have to get : This is an example of how to
Can someone help me???
Thanks 5 7820
Check out the Split method. Should get you on your way.
--
Adam Clauss ca*****@tamu.edu
"Paula" <ba*******@hotmail.com> wrote in message news:8f**************************@posting.google.c om... Hi !!
I have to find some words in a string. I can use string.IndexOf, LastIndexOf, etc, but they are case sensitive. And there is another problem : If I found the word, I have to get three words before and after the found word .
Example:
string s = "This is an example about how to find words in a string"; string wordToFind = "Example"
I have to get : This is an example of how to
Can someone help me???
Thanks
Paula,
you might want to check System.Text.RegularExpressions namespace and Regex
class. It can split strings using general definition of whitespace and word
boundaries, providing you with collection of indexes for found word - see
Matches, Groups and Captures collections there.
HTH
Alex
"Paula" <ba*******@hotmail.com> wrote in message
news:8f**************************@posting.google.c om... Hi !!
I have to find some words in a string. I can use string.IndexOf, LastIndexOf, etc, but they are case sensitive. And there is another problem : If I found the word, I have to get three words before and after the found word .
Example:
string s = "This is an example about how to find words in a string"; string wordToFind = "Example"
I have to get : This is an example of how to
Can someone help me???
Thanks
Looks like a job for the regular expression library unless this is a one
time thing and you can hard code it. Either way though I think regexs would
solve it for you.
--
W.G. Ryan, eMVP
Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know! https://www.windowsembeddedeval.com/...ity/newsgroups
"Paula" <ba*******@hotmail.com> wrote in message
news:8f**************************@posting.google.c om... Hi !!
I have to find some words in a string. I can use string.IndexOf, LastIndexOf, etc, but they are case sensitive. And there is another problem : If I found the word, I have to get three words before and after the found word .
Example:
string s = "This is an example about how to find words in a string"; string wordToFind = "Example"
I have to get : This is an example of how to
Can someone help me???
Thanks
> I can use string.IndexOf, LastIndexOf, etc, but they are case sensitive.
Just lowercase the string to search and get the positions from there on. Or
use regular expressions as suggested by another poster.
--
venlig hilsen / with regards
anders borum
-- And there is another problem : If I found the word, I have to get three words before and after the found word .
Example:
string s = "This is an example about how to find words in a string"; string wordToFind = "Example"
I have to get : This is an example of how to
Can someone help me???
Thanks
Hi !!
I think regular expressions are the best choice
Thanks This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Timo Haberkern |
last post by:
Hi there,
i have some troubles with my TSearch2 Installation. I have done this
installation as described in
http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_compound_words...
|
by: Steven |
last post by:
Hello,
I have a question about strcmp(). I have four words, who need to be
compared if it were two strings. I tried adding the comparison values
like '(strcmp(w1, w2) + strcmp(w3, w4))', where...
|
by: RSBakshi |
last post by:
Can any body tell me how to find duplicate lines in C
i have tried to find using Binary tree and Text files but not suceeded
..
It works for Word but not for lines
please help me
you can...
|
by: Csaba Gabor |
last post by:
I'm comparing the text of (snippets of) web pages which I expect to be
quite different or quite similar. In the case where they are similar,
I would like to display the more recent one and say...
|
by: dmurray14 |
last post by:
Hey guys,
I'm a C++ newbie here - I've messed with VB, but I mostly stick to web
languages, so I find C++ to be very confusing at times. Basically, I am
trying to import a text file, but I want...
|
by: Robert R. |
last post by:
Hello,
i would like to write a piece of code to help me to align some sequence
of words and suggest me the ordered common subwords of them
s0 = "this is an example of a thing i would like to...
|
by: inpuarg |
last post by:
I want to find a & character using Regex. But not &&
How can i manage this in c# Quickfind window ?
--------------------------------------------------
ne kadar yaşarsan yaşa
sevdiğin kadardır...
|
by: Johny |
last post by:
I need to find all the same words in a text .
What would be the best idea to do that?
I used string.find but it does not work properly for the words.
Let suppose I want to find a number 324 in...
|
by: Lambda |
last post by:
I'm trying to develop several interesting components
of a simple search engine follow some text books.
A book introduces some ways to compress dictionary,
allow it to stay on main memory.
In...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
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:
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: 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...
|
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: 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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
| |