vb.net extract first sentence in paragraph

  • Thread starter Thread starter dmalhotr2001
  • Start date Start date
D

dmalhotr2001

Hi,

For string extraction function in vb, if I feed in a paragraph, how do
I extract the first sentence of that paragraph.

Thanks

:D
 
re:
!> For string extraction function in vb, if I feed in a paragraph, how do
!> I extract the first sentence of that paragraph.

Dim sr As New IO.StreamReader("drive:\directory\somefile.txt")
sr.ReadLine()





Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
 
re:
!> Will that work if the first sentence is more than one line long?
!> Or if the first sentence is only a few words long?

That should read until the first line-break is found.
Some care will need to be taken when writing that first line. <g>

There's additional caveats, like if the punctuation includes a semi-colon.

Everything before the semi-colon will be interpreted as a line
and everything past the semi-colon ( and until the line-break)
will be interpreted as a second line.

re:
!> Don't you need to do some sort of regular expression where you find the
!> first instance of a full stop followed by a space and a capital letter...?

Finding the first period and reading everything that came before it would turn the trick, too.
There's also caveats with that method.

See my sig for an example : "Juan T. Llibre, asp.net MVP"

That line has a period followed by a space and a capital letter...but the line doesn't end there.

Bottom line: the problem is a tough nut to crack because of the infinite possibilities in text.



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
 
Back
Top