Print Page | Close Window

how to find the first sentence?

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=3212
Printed Date: 29 March 2026 at 1:47pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: how to find the first sentence?
Posted By: faubo
Subject: how to find the first sentence?
Date Posted: 02 June 2003 at 12:48pm

Hello,

I have a memo field in an access DB and I want to take the first sentence of the text in this field? Is this possible?

If I make it an array with the components of this array divided by " . " and use only the first component it will work?

maybe some js will do it... I don't know...

Thanks!



-------------
http://www.conhecerparaconservar.org - I don't know how to make you click here



Replies:
Posted By: ljamal
Date Posted: 02 June 2003 at 1:15pm
If correct punctuation is being used then use Instr(string, ". ") the find the position of the first periosd followed by a space and then truncate the text to that point.

string = Left (string, instr(string,". "))

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: MorningZ
Date Posted: 02 June 2003 at 2:26pm
if you use the above line.. make sure that a "." exists first, otherwise ***crash*** will go the Left function i believe

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: faubo
Date Posted: 02 June 2003 at 4:41pm

Thanks, I will try it soon, all the records have many " . "

I thought it would be much more complicated.



-------------
http://www.conhecerparaconservar.org - I don't know how to make you click here


Posted By: rlasker3
Date Posted: 10 June 2003 at 2:09pm

What if their first sentence is a question? Then it would have a question mark.

You may want to test for both conditions and then compare to see if one comes sooner than the other.



Posted By: Badaboem
Date Posted: 10 June 2003 at 2:36pm

Is there a way to grab a first image out of a string as well? I'm trying to think of a function to get an image out of a forum thread.



Posted By: MorningZ
Date Posted: 10 June 2003 at 2:43pm

Finding sentences ending in ".": Regular Expressions

Finding sentences ending in "?": Regular Expressions

Finding images: Regualr Expressions

Finding "oompa-loompa" in some text: Regular Expressions

Seeing a pattern here?

http://www.aspfaqs.com/aspfaqs/ShowCategory.asp?CatID=16 - http://www.aspfaqs.com/aspfaqs/ShowCategory.asp?CatID=16
http://www.regexlib.com - http://www.regexlib.com
http://www.google.com/search?sourceid=navclient&ie=UTF-8&oe=UTF-8&q=Learning+Regular+Expressions - http://www.google.com/search?sourceid=navclient&ie=UTF-8&oe=UTF-8&q=Learning+Regular+Expressions



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: ljamal
Date Posted: 10 June 2003 at 2:57pm
Regular Expressions are not always the fastest and/or the easiest method of finding things. In the case where you are lookng for the first instance of a specific characterm, Regular Expressions is not as fast as the good old InStr function.

In fact unless you need advanced character matching InStr is almost always more efficient than Regular Expressions. If you are trying to check if something could be a URL or email address, then use Regular Expressions. If you are trying to find the first sentence in a string use InStr.


-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net