I have a file with 100's of lines similar to this line;
41.6750,-81.4217,PGas,700 Cty Rd H,Elkharden,WA,362-623-5410
I want to end up with; comma's replaced w/ spaces around state abbr.
41.6750,-81.4217,PGas,700 Cty Rd H,Elkharden WA 362-623-5410
I've tried doing it a couple of ways but my problem in being new to textpad is how to use the expression to not only find the ,WA, but to put the same characters back with the _WA_ (underscore being a space of course)
I'm sure there are multiple ways to Find and Replace the two comma's before and after the state abbreviation. I have searched high and low on the forum but can't seem to find exactly what I'm looking for. There's a lot of documentation on the forum and any search pulls up hundreds of Topics on Search and Replace. Where's the best place to get specifics about how to do things using Regular Expressions? Preferably something that not only shows what the expressions are but explains in detail the breakdown of the syntax of the expression.
Appreciate any help...
Replacing characters after being used to find an item
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
There are many regular expression tutorials on the web, and you will find recommendations for some of them if you search this forum.Find what: ,([A-Z][A-Z]),
Replace with: _$1_ [Replace the underscores with spaces]
[X] Match case
[X] Regular expression
Replace All
A standard reference for regular expressions, which will tell you far more than you want to know, is
Friedl, Jeffrey E F
Mastering Regular Expressions, 3rd ed
O'Reilly, 2006
ISBN: 0-596-52812-4
http://regex.info/