Updated as this one works for all

```php
<?php


$paths = array(
    '/var/www/module/Digideck/src/Digideck/Entity/Definition/Foo' => 'Digideck\\Entity\\Definition\\Foo',
    '/var/www/library/Foo/Bar/Doo' => 'Foo\\Bar\\Doo',
    '/var/www/module/Foo/src/Foo/Entity/Definition/Foo' => 'Foo\\Entity\\Definition\\Foo',
);

foreach ($paths as $path => $class) {
    $search = explode('\\', $class);
    $search = array_shift($search);
    if (preg_match("!.*($search)/(.*)!", $path, $matches)) {
        var_dump($matches[1] . '/' . $matches[2]);
    }
}
```

```
string(30) "Digideck/Entity/Definition/Foo"
string(11) "Foo/Bar/Doo"
string(25) "Foo/Entity/Definition/Foo"
```