skip wrote:Hello m8,
its a data feed well multiple datafeeds I can loop through it line by line and even pin point the column to search I basicly need to assign the numeric parts of the sub strings to 2 vars one $txt and the other $mins
you can do this with a regular expression match with [MAN]preg_match[/MAN].
The regular expression I would use would be something like:
$regex_text = "/((\d{1,5})\s+(?:txt|text|texts))/";
$regex_min = "/((\d{1,5})\s+(?:min|mins|minute|minutes))/";
preg_match($regex_text, $data, $matches_text);
preg_match($regex_min, $data, $matches_min);
$txt = $matches_text[2];
$mins = $matches_min[2];
I tested this with a sample string and it works. You would of course need additional processing if the numbers can contain commas or decimal points, but that's pretty straightforward (process the data before it hits the regex to keep the regex matching to a minimum).