LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-22-2012, 02:35 AM   #1
sunlinux
Member
 
Registered: Feb 2006
Distribution: RHCL 5
Posts: 239

Rep: Reputation: 30
perl word extract


Hi I want to extract values between two characters

like

this is not:here we go:now don't do

I want to extract here we go from above line .. any help
 
Old 06-22-2012, 02:40 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
how do you define the delimiter char ? you can use split
 
Old 06-22-2012, 12:08 PM   #3
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
I agree that split is probably the most elegant. (You could also do this with regex and the binding operator.)

Code:
my $string = qq/this is not:here we go:now don't do/ ;

# Take a slice from split()
#
my $extract = (split(/:/, $string))[1] ;

print $extract . "\n" ;
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to extract numbers from a word using sed radhikamody Linux - Newbie 5 02-26-2012 12:05 PM
splitting a fil.e word by word. PERL casperdaghost Linux - Newbie 6 11-23-2010 05:45 AM
[SOLVED] How to extract the first word following a string Feynman Linux - Newbie 24 08-24-2010 12:27 PM
extract text only from ms word in php sriphp Linux - Newbie 2 05-11-2009 01:07 AM
How to extract Data from word document? nesta Programming 3 11-26-2008 11:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration