Click here to Skip to main content
13,452,206 members (55,395 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Dear friends,

First You will be thankful if u solved my problem...


I have developing window application for editing xml my problem was,how to select an sentence from paragraph based on a word.we need to select an sentence where the word exist from paragraph.

To be clear in the below example,we need to find the store in the paragraph tag content.then select the sentence where the store exist.

is it possible using regular expression concept?how?


<paragraph>mystery customer. Buckley continues to order Rasaratnam to hand over the cash and tells other customers to leave the store. Stick-up! Armed raider is overpowered in shop From Page One The dramatic CCTV footage shows shopworker Rasaratnam being ordered to put his hands on the counter, but he refuses to </paragraph >
Posted 30-Jan-13 22:09pm
Updated 30-Jan-13 22:12pm
VitorHugoGarcia 31-Jan-13 4:22am
the first thing that come to me mind is LINQ
jai_mca 31-Jan-13 4:31am
dear VitorHugoGarcia,thanks for ur reply..
if possible through linq means can u suggest a code?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Why not split the paragraph into sentences using string's split function on .(period/full stop). Then check for the word in each sentence one by one from the split-ed array and use the ones that contains the word and throw away the rest.
jai_mca 31-Jan-13 4:29am
yes rahul..i have the same idea.but how to get a sentence based on the period?
Rahul Rajat Singh 31-Jan-13 4:30am
if the paragraph is stored in a string called str then:

string[] splits = atr.split('.'); // convert this to VB code please
jai_mca 31-Jan-13 4:33am
many thanks rahul..i will check it out..
get in touch..
Rahul Rajat Singh 31-Jan-13 4:36am
if it works. close the question by marking it as answer so that people will know that it is solved.
jai_mca 31-Jan-13 4:42am
sure rahul..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.180318.3 | Last Updated 31 Jan 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100