Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear friends,

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

Description:

I have developing window application for editing xml content.now 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?


Eg:

VB
<keyword>store</keyword>
<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
Updated 30-Jan-13 22:12pm
v3
Comments
_Vitor Garcia_ 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

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.
 
Share this answer
 
Comments
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900