php regular expression question?
Posted on 2011-09-12
I have the following 3 lines of text and need a single regular expression to capture only the data. The data can contain any characters. The line with the word test can be (test1|test2|test3|test4)
1. test1 data- data
1. data- data
Here's what I tried to do but not working.
$remove_test_name = "(?:test1|test2|test3|test4)";
preg_match("/(?:\d+\.)? $remove_test_name (.*)\-(.*)/",$string,$matches);
echo $matches . "-" . $matches; The output I'm getting is this for line 1 (mention above):
for line 2
for line 3
What I would like is this: