Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - how to find the first sentence?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

how to find the first sentence?

 Post Reply Post Reply
Author
faubo View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 May 2002
Location: Brazil
Status: Offline
Points: 560
Post Options Post Options   Thanks (0) Thanks(0)   Quote faubo Quote  Post ReplyReply Direct Link To This Post Topic: how to find the first sentence?
    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!

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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,". "))
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
faubo View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 May 2002
Location: Brazil
Status: Offline
Points: 560
Post Options Post Options   Thanks (0) Thanks(0)   Quote faubo Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
rlasker3 View Drop Down
Newbie
Newbie


Joined: 10 June 2003
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote rlasker3 Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
Badaboem View Drop Down
Senior Member
Senior Member


Joined: 12 April 2002
Location: Netherlands
Status: Offline
Points: 600
Post Options Post Options   Thanks (0) Thanks(0)   Quote Badaboem Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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.regexlib.com
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
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.