Use Google Sheets instead of Excel - this feature is built in, so you can use regex right from the find and replace dialog.
To answer your question:
- Copy the data from Excel and paste into Google Sheets
- Use the find and replace dialog with regex
- Copy the data from Google Sheets and paste back into Excel
Use Google Sheets instead of Excel - this feature is built in, so you can use regex right from the find and replace dialog.
To answer your question:
- Copy the data from Excel and paste into Google Sheets
- Use the find and replace dialog with regex
- Copy the data from Google Sheets and paste back into Excel
Apparently, Excel does not use Regex, but there is a workaround. You can use *, ? or ~ in your search pattern.
To find
? (question mark) = Any single character. For example, sm?th finds "smith" and "smyth"
* (asterisk) = Any number of characters For example, *east finds "Northeast" and "Southeast"
~ (tilde) followed by ?, *, or ~ = A question mark, asterisk, or tilde. For example, fy06~? finds "fy06?"
you can use these combinations to get a similar pattern that will be close to a regex expression.
What would be the best way to find and replace all regular expression symbols in a data set? I’m trying to clean all the data before uploading to a table.
I found a way to do it in Notepad ++, but I’m having a hard time finding a way to do it in excel.
Are you talking Regex?
Excel only uses Regex through VBA (unless you're talking about a UDF), and even then, that's only if the Regex reference has been added. If you're talking about in VBA, each Regex would be tied to some variable, depending on how it was defined. You could still possibly pick up on the .Pattern property, though that would really only put you in the vicinity of where they're occurring.
If you're talking about in worksheets, then I'm guessing you're either
a) talking about a UDF (use the UDF as the search string with the asterisk [*] wildcard, such as *UDF*); or
b) the pattern itself (you'd need to provide more info).
Not sure how else you'd have regular expressions within your data set, since a Regex is really nothing more than an expression used in a search box. It't be similar to storing a list of Find strings used when pulling up the Find and Replace box with Ctrl+f. If the dataset doesn't already delineate the Regex patterns from normal text or formulas, you could potentially replace non-Regex data.
Ctrl+H brings up a find and replace prompt.
Excel's pattern matching capabilities are extremely limited: literal characters, * to match any number of unspecified characters, and ? to match a single unspecified character. There is no native match placeholder capability, either in worksheet functions or in VBA.
However, as Excellll noted, you can use regex in VBA, and can develop user-defined functions that are regex-based.
To access regex in your code, add a reference to the "Microsoft VBScript Regular Expression 5.5" library via the Tools->References selections in the main menu for the Visual Basic code editor.
I have not found any comprehensive documentation for the library, but you can find a lot of bits and pieces - and example code - with a Google search.
Though this is a very late answer, I have had success with an add-in called RegEx Find/Replace to do exactly what you want. But I do not know of any built-in capability for this in Excel.
The add-in creates a button on the ribbon which launches a dialog box that looks very much like the Excel Find/Replace. Most of it works the same as well - you can search within a sheet or workbook, by columns or rows, match case, etc. (There is no format matching, though.)
Note, however, that the add-in uses regular expressions as implemented in VBScript and so works differently than the standard Excel Find/Replace. For example, your search string _* would not work. It matches any cell with zero or more underscores, which is anything. For your example, I had success finding _(\d+) and replacing with '($1). (The apostrophe is just to prevent Excel from interpreting (4) as a negative value.)
I am in no way affiliated with the website or developer - just found it through a web search. Also, I use Excel 2007 and cannot say whether this still works in later versions. I have used it successfully in both Windows 7 and Windows 10.
The RegEx Find/Replace add-in can be found at http://www.codedawn.com/excel-add-ins.php
Let's assume that you have a long column of these numbers in column A of an Excel worksheet, starting with cell A1.
In cell B1, enter =",'"&A1&"'"
Then autofill down: select cell B1, hover over the square that appears at the bottom-right corner of the cell, and double-click. (If you have any gaps in the column of numbers, you may need to drag down on the square instead.)
Now right-click on the column heading and choose Copy, then right-click again and choose Paste Values.
Ctrl+h does the trick. Is built in in excel and word.
In Excel you can e.g. mark only one column or one row and do then your replacement with Ctrl+h . That way you keep other columns/ rows untouched.