Jump to content

how to extract (very simple)


AndyPSV

Recommended Posts

I'VE GOT.

 

  Quote
question_comment

42

51

553

12

55421

 

answer_comment

3221

321

12

145

667

 

post_comment

12321

1212

1221

1212

11

1

 

 

I WANT.

 

get everything which is after variable, let it be for example: answer_comment, so the result needs to be:

 

  Quote
3221

321

12

145

667

 

 

so we theoretically delete the variable and we take all until the next "\r\n\r\n"

 

how to do that

any preg_match?

Link to comment
https://forums.phpfreaks.com/topic/252661-how-to-extract-very-simple/
Share on other sites

You will need to use a look-behind. Be aware a look-behind has to be a fixed length (i.e. not a pattern). It would go something like:

 

[This is untested]

<?php
$variable = 'answer_comment';
preg_match("/(?<=$variable)[^A-Za-z]+/sm", $subject, $match);

 

That's looking for something that begins with the variable and is not letters and can happen between one and infinity times.

 

Hope that helps,

Joe

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.