Re: Extract part of a string



On Apr 30, 9:53 am, Paul Lalli <mri...@xxxxxxxxx> wrote:
On Apr 30, 9:21 am, roopa...@xxxxxxxxx wrote:





Hi,

I want to extract everything between the hash signs in the following
string

"### This is a test ###"

I am using the following..

if($desc=~ /\#{3}(.*?)\#{3}/ )
{
print $1;

}

I am not getting the desired result. Please tell me what I am doing
wrong.

What you're doing wrong is not posting a short-but complete script
that demonstrates your error. Because what you have above *does*
work. So therefore you're doing something wrong in your actual code
that you haven't bothered to show us...

$ perl -e'
my $desc = "### This is a test ###";
if($desc=~ /\#{3}(.*?)\#{3}/ )
{
print $1;}

'
Results: This is a test

Paul Lalli- Hide quoted text -

- Show quoted text -

My String contains new line characters like
"This is a test

BEGIN PART INFORMATION##
5G5E-6010-AA|BLK ASY-CYL|
##END PART INFORMATION

"

So how do i modify my regexp


.



Relevant Pages

  • Re: form processing spammed
    ... This could be as simple as posting a string length variable for each or ... processor/emailer page script. ... form and compare it with a key generated by the processor page. ...
    (comp.lang.php)
  • Re: RegExp() to strip comments in CSS?
    ... the last posting, so netiquette says: always quote relevant part that posting ... And what system you are you are using, since perhaps the newline representation could not be recognized in the conversion to a string. ... I have since written a two line old school ditty to do the task, but I still want to figure out how to make it happen in RegExp(), preferably in a single expression. ...
    (comp.lang.javascript)
  • Re: Replicated DB and synchronize with PPC with active Sync
    ... This posting is provided "AS IS" with no warranties, ... > How did you convert the s_Guid into String? ... >>> Globalization Infrastructure and Font Technologies ...
    (microsoft.public.access.replication)
  • RE: Possible?
    ... declare @ptr binary ... -- Export the table using comma as the row terminator. ... -- Return the string as a result set. ... This posting is provided "as is" with no warranties and confers no rights. ...
    (microsoft.public.sqlserver.programming)
  • Re: Help with my program (code inside)
    ... This string contains the common elements of the strings in A and B. ... What about the copy constructor and the assignment operator? ... Scrolling through your source code I see: ... posting and just using what you have written try to answer: ...
    (comp.lang.cpp)