CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
regular expression help

 



kogantiuday
Novice

Jul 26, 2007, 11:35 PM

Post #1 of 3 (2479 views)
regular expression help Can't Post

1) how to extract first word from a sentence without splitting

2) how to extract nth word from a sentence without splitting


KevinR
Veteran


Jul 27, 2007, 3:01 AM

Post #2 of 3 (2476 views)
Re: [kogantiuday] regular expression help [In reply to] Can't Post

what have you tried so far?
-------------------------------------------------


winfinit
User

Oct 9, 2007, 7:19 PM

Post #3 of 3 (2411 views)
Re: [kogantiuday] regular expression help [In reply to] Can't Post

first word could be something like this $entry=~/^[*?] /;

for further info read through regex tutorials

In action:
============
winfinits-computer:~ winfinit$ cat test
this is the sentence. and this is anothher one
also this is another line
and this is my last line

winfinits-computer:~ winfinit$ cat test.pl
#!/usr/bin/perl

@test=`cat test`;
foreach (@test)
{$_=~/^(.*?) /;
print "$1\n";}

winfinits-computer:~ winfinit$ perl test.pl
this
also
and
======================

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives