How to select data by column/header name

Hi,

I have over 300 columns with different header names. Is there a way I can select only those columns containing "A" or "B"?

Here is what I have tried that works:

newdf <- select(olddf, contains("A"))

This code works, but I am trying to incorporate 2 conditions within the above statement. For example the below does not work:

newdf <- select(olddf, contains("A" | "B"))

Thank you

This will work:

select(iris, c(contains(".Length"), contains(".Width")))

Thank you for the prompt response!