Question: What is the regex to match the following strings:

```
base.string
a.base.string
b.base.string
cde.base.string

```

This should not match:

```
a.b.c.d.base.string
abase.string
bbase.string
cdebase.string
.base.string

```

I want to match and capture a, b, cde, and the empty string from "base.string"

(a, b, cde are used as example. what can come before base.string is empty string, or any non-empty string followed by a dot.)

Answer: 
The datasource used by a thread might change from time to time.  

Should pay attention to concurrency, applications might get concurrency issues in concurrent environment.  

[thread-bound AbstractRoutingDataSource sample](https://spring.io/blog/2007/01/23/dynamic-datasource-routing/)
It can be achieved with AbstractRoutingDataSource and keeping the information in the thread-local Variable. Here is a beautiful working example you can refer to:
[Multi-tenancy: Managing multiple datasources with Spring Data JPA](https://stackoverflow.com/questions/49759672/multi-tenancy-managing-multiple-datasources-with-spring-data-jpa/)