PDA

View Full Version : Regex in Excel 2007



guthrie
04-03-2009, 10:42 AM
I want to do some simple name decoding,
exactly like:
kb/getarticle.php?kb_id=68

But the download link on that page gives me a broken file.

How do I enable regular expressions in Excel 2007,
and perhaps a simple example of decoding a "Last, First M." name?

I expected to do something like:
=regex.execute(A23, "\w+, (\w) .*")
directly in a cell, not writing a VB function.

I saw some VB utility plugins like "regMatch", are those what is needed?

Microsoft site search for "excel regular expressions" gives nothing (!?).

I did enable the regular expressions add-in in VBA from Excel, and thought this should make the functions available in spreadsheet cells, but not so far...

Bob Phillips
04-03-2009, 11:46 AM
You can't put RE directly in a cell, you would need a UDF VBA wrapper for it.

guthrie
04-03-2009, 11:49 AM
Thanks.

(Odd, but better to know it).

Are there a standard (or recommended) set of such wrappers?

Regex are so standard, it would seem like a standard fare.

For example;
dailydoseofExcel - archives/2005/08/13/pattern-matching/
is a simple example, but how do I install it?
(sorry for excel VBA ignorance!)

Bob Phillips
04-03-2009, 01:18 PM
That post seems to explain it pretty well. Which bit are you struggling with?

guthrie
04-03-2009, 05:22 PM
No problem. I got it.

What I was wanting to know is where to put the code - I put it into the standard module, and it works fine.

And just if there were standard wrappers /interfaces for this.