<p>Here I am faced with an issue that I believe(or at least hope) was solved 1 million times already. 
What I got as the input is a string that represents a length of an object in imperial units. It can go like this:</p>

<pre><code>$length = "3' 2 1/2\"";
</code></pre>

<p>or like this:</p>

<pre><code>$length = "1/2\"";
</code></pre>

<p>or in fact in any other way we normally would write it.</p>

<p>In effort to reduce global wheel invention, I wonder if there is some function, class, or regexp-ish thing that will allow me to convert Imperial length into Metric length?</p>

The regexp would look something like this:
```
```
"([0-9]+)'\s*([0-9]+)\""
```
```
(where \s represents whitespace - I'm not sure how it works in php). Then you extract the first + second group and do
```
```
(int(grp1)*12+int(grp2))*2.54
```
```
to convert to centimeters.