Regex, String function, Help!

Posted on 2000-02-08
Medium Priority
Last Modified: 2010-03-05
Ok, I have a huge string called  $text . It has a page of written
text on it.
I want to try and get most of the regular sentences out of it.
My idea is to look between  " .;?! " (period, question mark, etc...)
and return the sentence between them.
I just need the words between all "end of sentence characters".

How do I do this?

$mysentence= # everything between "end of sentence characters".

P.S. I could do this with a bunch of for loops, etc.... thought
there might be a more eloquent way with one statement.
Question by:jgore

Accepted Solution

amitpagarwal earned 300 total points
ID: 2499567

@wordsinline = split(" ",$line)
foreach $word(@wordsinline)
if $word !~ [;!:]
   print $sentence
   $sentence =. $word

check the syntax - i hope u get the broad idea.

LVL 85

Expert Comment

ID: 2501702
foreach $mysentence (split/[.;?!]/,$text){ print "$mysentence\n" }

Author Comment

ID: 2502361
Thanks  amitpagarwal and Ozo!
Both work, but I think Ozo's was more what I was looking for.
I just finished chapter on regex and will have to
look at Ozo's comment a while (true JAPH ;-) .

Anyways, thanks to you both!

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Article by: Tammy
MySQLTuner is a script written in Perl that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data is retrieved and presented in a brief forma…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

593 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question