Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

greping data

Posted on 1999-07-07
6
Medium Priority
?
219 Views
Last Modified: 2010-03-04
given some text ...

From me Wed Jun 23 14:29:10 1999
X-Sender: me@mail.mynet
X-Mailer: Windows Eudora Pro Version 3.0 (32)
Date: Wed, 23 Jun 1999 14:30:32 +0800
To: me@mynet.net
From: me
Subject: multipart message test
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="=====================_930090632==_"

How would be extract the boundry string and place it in $boundary.

thanks
0
Comment
Question by:angieteh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 19

Expert Comment

by:Kim Ryan
ID: 1213954
Assuming you are OK with getting the line contents into a variable:

$line =~
  /^Content\-Type: multipart\/mixed;boundary="(.*)"$/;
$boundary = $1;
0
 

Author Comment

by:angieteh
ID: 1213955
can you please explain what that does ?
0
 

Author Comment

by:angieteh
ID: 1213956
i'm sure it works ...
but can you please explain what it does ... and resubmit answer to get the points.

thanks
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Expert Comment

by:olthoff
ID: 1213957
$line =~
  /^Content\-Type: multipart\/mixed;boundary="(.*)"$/;

$boundary = $1;

The first line looks for the line "Content... The "(.*)"$ says take everything after the first " until the " at the end of the line and store it in $1 (a reserved variable)

The next line stores $1 into the $boundary variable.
0
 
LVL 19

Accepted Solution

by:
Kim Ryan earned 200 total points
ID: 1213958
$line =~
  /^Content\-Type: multipart\/mixed;boundary="(.*)"$/;
$boundary = $1;

=~ binds the regular expression search to the $line variable, rather than the deafual of $_ .

^ means the line must start with this pattern

The '-' and '/' chars ares interpreted literally by preceeding them a '\' becuase they have special meanings inside regexps.

Everything inside brackets are retained as a group. THe first group is called $1, secund $2 etc.

The final "$ mean the pattern must end with a double quote.

Becuase $1 can be reset by any future regular expression, i'ts contents needs ot be saved the variable $boundary.

Hope this explains it.

0
 
LVL 84

Expert Comment

by:ozo
ID: 1213959
'-' does not have a special meaning inside regexps
'/' only has a special meaning inside strings quoted with /
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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…
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

705 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