Q&A > regular expressions > How do I get what is to the left of my match? contributed by fundflow
$_="left center right";
Keep in mind that /(center)/ will match the
occurence of 'center' in the string, while
/(.*)(center)(.*)/ will match the
occurence of center (leaving aside for the moment the issue of newlines).
I have absolutely zero preference
Results (123 votes),