preg_match_all with surrounding data
Posted
by
user323304
on Stack Overflow
See other posts from Stack Overflow
or by user323304
Published on 2010-12-21T17:51:47Z
Indexed on
2010/12/21
17:54 UTC
Read the original article
Hit count: 157
Hey.
I have a large amount of log data that I need to get some relevant information out of. The syntax is:
WORD1 some text KEYWORD some text WORD2 WORD1 some text KEYWORD some text WORD2 WORD1 some text KEYWORD some text WORD2 WORD1 some text KEYWORD some text WORD2
Would it be possible to use regex to get a certain block out of it - so that when I queried some keyword it would return WORD1 some text THIS_KEYWORD some text WORD2
PS: There could be multiple instances of one keyword, it should return all of the blocks (preg_match_all, PREG_SET_ORDER?).
© Stack Overflow or respective owner