LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-20-2007, 01:35 AM   #1
abdul_zu
Member
 
Registered: Feb 2005
Posts: 71

Rep: Reputation: 15
Perl Regular Expression


HI All,

I have a small problem to separate two string from one line. Could you please help me how i can do this following string using regular expression or with other method by Perl Language.

i have following values in variable but before and after '->' some time can be other numbers and char.

$var1 = "00->254157474#;";
$var2 = "585758->;"

i need to put like:

$before1 = 00;
$after1 = "254157474#";

same for second line

$before2 = 585758;
$after2 = "";

I will be appreciate for your kind of help.

Thank You
Lateef
 
Old 08-20-2007, 02:53 AM   #2
googlebot
LQ Newbie
 
Registered: Jan 2007
Posts: 1

Rep: Reputation: 0
$before = $after = $var1;

$before =~ s/(.*)->(.*)/$1/;
$after =~ s/(.*)->(.*)/$2/;

hope you'll figure out remaining parts ^)
 
Old 08-20-2007, 03:57 AM   #3
abdul_zu
Member
 
Registered: Feb 2005
Posts: 71

Original Poster
Rep: Reputation: 15
Thank You very much it is working well.
 
  


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
perl regular expression problem true_atlantis Programming 4 05-27-2009 06:35 AM
Perl regular expression issue zikhermm Programming 7 09-23-2005 03:48 PM
Having trouble with a perl regular expression... jayemef Programming 3 08-25-2005 11:00 PM
Perl Regular Expression rch Programming 14 07-11-2003 11:00 PM
using a perl regular expression in php markus1982 Programming 5 11-18-2002 02:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:37 AM.

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