regex: adapt to locking regime instead of depending on pthread