How do I write this regex pattern?

I have a padas dataframe, from which I want to extract certain values: (' APT 2E'), (' 2ND fl'), (' #5B'), (#568'), (#1 FL' ), (FL 2' )

What kind of regex pattern would I write to select only these kind of values?

Start a personal dev blog on your domain for free and grow your readership.

3.4K+ developers have started their personal blogs on Hashnode in the last one month.

Write in Markdown 路 Publish articles on custom domain 路 Gain readership on day zero 路 Automatic GitHub backup and more

Hipkiss's photo :)
Have fun.

j's photo

([\w #]+) will get all the characters between the brackets and the extra spaces.

The problem I have your specification 'this kind of pattern' providing an inconsistent data sample makes it hard to discern what you actually want.

the idea of giving examples you should at least give an expected result. either you think like a function

F(input) -> output

or at least some hint what the expectation of the result should be.

Btw in your case there are multiple solutions an they depend on scale, maybe regex is the wrong solution if you got a repeating pattern you can use cursor based buffer parsers packed into generators/coroutines.