0

Complete regex noob in Excel here

I have a column which contains a combination of multiple fields with only a space to separate them (despite spaces being elsewhere in the field).

The only way to tell the parts apart is that the first part is all caps where as the second can be anything (and while it can contain a capital letter, I have confirmed that it is never exclusively all capital letters).

I need to extract the all caps part, and remove everything afterwards.

I've looked for RegEx in Excel and have only been pointed towards VBA. Is there another approach that is possible?

Daniel V
  • 1,305
  • 7
  • 23
  • https://stackoverflow.com/questions/22542834/how-to-use-regular-expressions-regex-in-microsoft-excel-both-in-cell-and-loops . If you want to play around with regex before getting into the complexity of regex in excel, regexr.com and regex101.com,among others, are a good place to start. Just be aware that VBA uses a somewhat different "flavour" of regex. – Stax Mar 16 '22 at 02:18
  • Without sample data it's a bit hard to tell, but according to what you wrote the linked duplicate seems to tick your boxes. – JvdV Mar 16 '22 at 07:01
  • 1
    @JvdV: I truly wanted to see your stab at it. This is a case for [FILTERXML](https://stackoverflow.com/a/61837697), right? – VBasic2008 Mar 16 '22 at 07:03
  • @vbasic2008, yes reading OPs requirements (space delimited words, only uppercase words) it appears the linked dupe (using FILTERXML) would work. – JvdV Mar 16 '22 at 07:09
  • @JvdV: Wasn't the requirement all words until you hit a word containing a non-uppercase letter? It may be a little bit different for you, but for a noob like me, it's 'the whole world'. – VBasic2008 Mar 16 '22 at 07:20
  • 1
    Yes @VBasic2008, that could also definitely be possible. It may need a small tweak in the xpath expression to cater for that. I think, however, it's fair enough to close this as a duplicate (instead we could/should have closed the question for many more reasons). – JvdV Mar 16 '22 at 07:23

0 Answers0