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 7835
Check out the Split method. Should get you on your way.
--
Adam Clauss ca*****@tamu.ed u
"Paula" <ba*******@hotm ail.com> wrote in message news:8f******** *************** ***@posting.goo gle.com... 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.Reg ularExpressions 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*******@hotm ail.com> wrote in message
news:8f******** *************** ***@posting.goo gle.com... 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*******@hotm ail.com> wrote in message
news:8f******** *************** ***@posting.goo gle.com... 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 <http://www.sai.msu.su/%7Emegera/oddmuse/index.cgi/Tsearch_V2_compound_words>
I used the german myspell dictionary from
http://lingucomponent.openoffice.org/spell_dic.html and converted it with
my2ispell
|
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 w1 and w2 make up the
first string and, w3 and w4 make up the second string. I do not want
to allocate memory, then put the words together to create a string
only to facilitate strcmp() comparison.
My question; Does anyone know how to get the...
|
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 write suggetion to my email : rsbakshi@gmail.com
|
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 something like:
Word 2 added : "Jack be nimble"
Words 10-11 changed to: "the quick brown fox"
: "the brown fast quick fox"
Words before word 20 removed: "sat in a corner on"
|
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 to do it word by word. I am
confused as to how to do this. Typically, I would think it would make
sense to try and input the words into strings, but for this application
I need to use character arrays and pointers. So what's the best way to
go...
| |
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 have".split()
s1 = "another example of something else i would like to have".split()
s2 = 'and this is another " example " but of something ; now i would
still like to have'.split()
....
|
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 ömrün :(
--------------------------------------------------
|
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 the text
'45 324 45324'
there is only one occurrence of 324 word but string.find() finds 2
occurrences ( in 45324 too)
|
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 the dictionary, is a list of millions of words
with related data of several bytes.
Word / Term Freq(int) / Pointer to disk file
Hello 100
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |