Regular expression search/replace in Excel

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

Without delving into VBA (I have limited experience, and now is not
the time to learn), and without installing augmentation software, is
it possible to search for all text matching a search pattern, then
prepend each occurance with given sequence of characters?

If not, is it possible to simply prepend a given sequence of
characters the string in each cell of a selected region?

Thanks.
 
You could make a loop through these cells, and use Like to test whether the
cells match some kind of pattern. See in the helpfiles for the wildcards you
can use.
 
This formula might work in your situation. B5 being the cell to analyse,
"There" being the text you are looking for and "Hello" as the text to prepend.

Find is case sensative.

=IF(ISERR(FIND("There",B5)),B5,"Hello " & B5)

Tom
 
Wigi,

I appreciate the tip. I was hoping that there was a way to do it
without delving in to VBA (and I wasn't clear about that in my OP, now
that I review it). From the responses so far, I assume that it is not
possible.
 
Tom,

Thanks for the code snippet. I wasn't clear in my OP, but I was
seeking a non-VBA method of search-and-replace with regular
expressions. But from the lack of responses in that vein, I'm
assuming that there isn't such a solution.
 
Is this something you're looking for:

Text in A2 to An.

To insert the text:
P.O. #
at the beginning of each cell.

In A1 enter:
P.O. #

Enter this formula anywhere:

=A$1&" "&A2
And copy down as needed.
 
Is this something you're looking for:

Text in A2 to An.

To insert the text:
P.O. #
at the beginning of each cell.

In A1 enter:
P.O. #

Enter this formula anywhere:

=A$1&" "&A2
And copy down as needed.

RD, that does indeed help, and fits the bill of my currently limited
Microsoft experience. Thank you!
 
In re-reading your OP, are you looking to ... say ...
add that "P.O. #" text to *only certain* cells that might contain a specific
text string?

If you're still looking for help in that vein, post back with some
specifics.
 
Tom,

Thanks for the code snippet. I wasn't clear in my OP, but I was
seeking a non-VBA method of search-and-replace with regular
expressions. But from the lack of responses in that vein, I'm
assuming that there isn't such a solution.

Microsoft Excel does not support regular expressions.

VBA supports the Javascript flavor.

Longre has written a free add-in: morefunc.xll which as regular expression
functions which support the PCRE flavor. Apparently because it is an .xll, it
will not work with strings > 255 characters, though. You can find it here:
http://xcell05.free.fr/english/index.html

--ron
 
Yes, that is what I meant in my first paragraph. RD's solution help
if I want to manually go through and find these cells myself.
 
Microsoft Excel does not support regular expressions.

VBA supports the Javascript flavor.

Longre has written a free add-in:  morefunc.xll which as regular expression
functions which support the PCRE flavor.  Apparently because it is an .xll, it
will not work with strings > 255 characters, though.  You can find it here:http://xcell05.free.fr/english/index.html

Thank you, Ron. Unfortunately, I have to use functionality within
Excel.
 
Thank you, Ron. Unfortunately, I have to use functionality within
Excel.

Well, if you can't use VBA, and can't use add-ins, the only other tool of which
I am aware would be the Find/Replace within Excel. That tool does not support
regular expressions.
--ron
 
Exactly *what* cells are you looking for?

Is it one specific text string or number, or multiple ones?
 
Multiple strings.

Exactly *what* cells are you looking for?

Is it one specific text string or number, or multiple ones?
--

Regards,

RD
-----------------------------------------------------------------------------------------------
Please keep all correspondence within the Group, so all may benefit !
-----------------------------------------------------------------------------------------------


Yes, that is what I meant in my first paragraph. RD's solution help
if I want to manually go through and find these cells myself.
 
Well, if you can't use VBA, and can't use add-ins, the only other tool of which
I am aware would be the Find/Replace within Excel. That tool does not support
regular expressions.
--ron

Understood. It really puts the pressure on carving out time to learn
VBA.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top