Get Region Id given Region Code and country id

This has to work

$region = $this->_regionFactory->create();
$regionId = $region->loadByCode($code, $country_id)->getId();

Try below code:

<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$region = $objectManager->create('Magento\Directory\Model\Region')
                        ->loadByCode('CA', 'US');
print_r($region->getData());
?>

Output:

Array
(
    [region_id] => 12
    [country_id] => US
    [code] => CA
    [default_name] => California
    [name] => California
)

Note: Please do not use Object Manager. Instead create function and then call it.