Current location: Hot Scripts Forums » Programming Languages » PHP » Regular Expressions


Regular Expressions

Reply
  #1 (permalink)  
Old 12-08-03, 02:10 PM
helpcenterlive helpcenterlive is offline
New Member
 
Join Date: Oct 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Regular Expressions

Im trying to match anything, including lines between two points and output everything except the points e.g.

## START ##
all
of
this
will
be
returned
## END ##

will display:

all
of
this
will
be
returned


I have tried everything, the closest I have got is this, but it does not match new lines:
preg_replace("/## START ##(.*)## END ##/s", "\\1", $string);

Please Help!
Mike
Reply With Quote
  #2 (permalink)  
Old 12-08-03, 05:36 PM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,171
Thanks: 3
Thanked 9 Times in 9 Posts
Why not:

// ## Start ##
all
of
this
will
be
returned
// ## End ##

But that is assuming that you actually trying to do PHP code, and not Perl. Did I understand your question correctly?



Quote:
Originally Posted by helpcenterlive
Im trying to match anything, including lines between two points and output everything except the points e.g.

## START ##
all
of
this
will
be
returned
## END ##

will display:

all
of
this
will
be
returned


I have tried everything, the closest I have got is this, but it does not match new lines:
preg_replace("/## START ##(.*)## END ##/s", "\\1", $string);

Please Help!
Mike
__________________
Reply With Quote
  #3 (permalink)  
Old 12-08-03, 06:56 PM
Skeleton Man Skeleton Man is offline
Community Liaison
 
Join Date: Jun 2003
Location: Australia
Posts: 406
Thanks: 0
Thanked 0 Times in 0 Posts
This should work:

Code:
<?
$data = <<<END
## START ##
all
of
this
will
be
returned
## END ##
END;

$txt = preg_replace("/## START ##(.*)## END ##/s", "\\1", $data);
print $txt;
?>
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expressioning []'s AbelaJohnB PHP 8 12-04-03 02:37 PM


All times are GMT -5. The time now is 06:11 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.