<?php
$re = "/(?<=affiliatewire_)[^_\r\n]++/";
$str = "param0_test1_param1_affiliatewire_name1_test2_param2_param3
param0_test1_param1_affiliatewire_name_test2_param2_param3
param0_test1_param1_affiliatewire_trollolo_test2_param2_param3";
preg_match_all($re, $str, $matches);
print_r($matches);
?>
Array
(
[0] => Array
(
[0] => name1
[1] => name
[2] => trollolo
)
)
$main_str = 'abracadabra-cudsa_123-qwerty-text_a-abraca-trollololo-nlo';
//искомый текст
$my_str = '/text_a|text_b/';
$matches = array();
preg_match_all($my_str, $main_str, $matches);
if (array_search('text_a', $matches[0]) !== false)
echo 'Привет, Васа!';
elseif(array_search('text_b', $matches[0]) !== false)
echo 'Привет, Лана!';
else
echo 'Привет, Мир!';