Reputation: 1457
I have the following string in php:
$text = "This price excludes vat and blah blah blah ......";
and the start of regex :
preg_match("/(--not sure what goes here--)(?: vat)/", $text, $vatStatus);
Basically I would like to get the first letter of the word before vat (in this case the letter 'e').
In advance thanks for the help.
PS. the solution needs to be specifically in regex and not any other PHP functions.
Thanks
Upvotes: 1
Views: 267
Reputation: 191749
/\b(\w)\w*?(?: vat)/
This should capture your first letter.
Upvotes: 3