?
Solved

Regex, String function, Help!

Posted on 2000-02-08
3
Medium Priority
?
155 Views
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.
0
Comment
Question by:jgore
3 Comments
 
LVL 5

Accepted Solution

by:
amitpagarwal earned 300 total points
ID: 2499567

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

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

thanks
0
 
LVL 85

Expert Comment

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

Author Comment

by:jgore
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!
0

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