Find And Replace wildcard

9046
7
03-30-2016 05:35 PM
PeterIsaksen
New Contributor II

Is there a wildcard I can use in Find and Replace so that I can get rid of things like 'BLDG 7', or 'UNIT A' from the end of addresses. I am trying to match addresses to an address file that does not include the Unit numbers of BLDG numbers. Is there a way to eliminate these types of details from the end of this text string? I can find them with Select by Attributes where (MyTableName) LIKE '% BLDG %' brings back the records, but in the table I am working on this brings back 1752 records and that is way too many to hand correct...

0 Kudos
7 Replies
PeterIsaksen
New Contributor II

Oops I meant (MyFieldName) not (MyTable Name)

0 Kudos
DanPatterson_Retired
MVP Emeritus

There are many options but probably not one that is going to fit all cases.  For example, here are a few that aren't universal but demonstrate the principles of parsing by string, substitution.  A set of sample rows would help, but try not to strive to the all encompassing one-click solution

>>> a = "some address Bldg 7"
>>> a.find("Bldg")
13
>>> b = a[:13]
>>> b
'some address '
>>> a.replace("Bldg 7","")
'some address '
ChrisDonohue__GISP
MVP Alum

One possible approach:

It sounds like you are trying to parse an address out of a single field.  If that is the case, are all the Buildings and Units in the same sequence in a record, specifically does "Unit A" and "Building 7" always fall between say the street and the city?

For example:

123 Main St Unit 4 Sacramento CA 95814

456 Main St Bldg 7 Sacramento CA 95814

If that is indeed the case, you throw together code to capture everything up to and including "ST" (and all the other common road suffixes, like AV, BL, RD, etc), then capture from "Sacramento" (the city)  onwards, and then concatenate the result.  (I'll leave the specific coding of how to do this in Python to the experts, but I know this can be done in VB and other languages).

However, this will all depend on how your data is arranged.  If it is OK to do so, can you post sample of your data?  That would help folks immensely in suggesting solutions (including coming up with specific code).

Chris Donohue, GISP

ChrisDonohue__GISP
MVP Alum

Another thought:

I know some folks in the addressing part of the GIS world have to do bulk parsing of addresses to get addresses broken down into their component parts so they can be used for things ranging from Emergency/911 response to day to day administrative tasks.  For example, most municipalities have address data parsed down to components similar to the US Thoroughfare, Landmark, and Postal Address Standard ()United States Thoroughfare, Landmark, and Postal Address Data Standard — Federal Geographic Data Co... ).  So addresses get broken down into pieces.  For example, a Street would get parsed into component fields like:  StreetPreDirection, StreetNameSuffix, StreetName, etc.

My point is there are existing processes people have developed to do the parsing.  If you could get ahold of one of these processes, you could theoretically run it on your address data and then recombine only the pieces you need (i.e. ignore the Units and Buildings).

So I guess the appeal now is to the GeoNet community.  Would any of you GeoNet folks be willing to offer up some code/processes to the original poster so he can do this?  (Sorry, I don't have any myself.  While I do assign addresses at the City I work at for new development, I don't work with existing data that needs to be parsed down (I get to create it in the first place )).

Let me tag a probable culprit expert on this sort of thing:  https://community.esri.com/migrated-users/4422

Chris Donohue, GISP

0 Kudos
JoeBorgione
MVP Emeritus

Hey... I resemble that! ( Chris Donohue, GISP​   ... )

Thanks to Darren Wiens​ I have become co-dependent on some python code listed here:  A better way to parse an address?

All seriousness aside, It could easily be adapted to the specific need of the o.p.

That should just about do it....
PeterIsaksen
New Contributor II

First of all, thanks everyone for the suggestions. I tried a few and they really didn't make the task seem any easier. So I did some more digging and found this webpage on another forum http://stackoverflow.com/questions/6266727/python-cut-off-the-last-word-of-a-sentence

I modified the python statement a bit, but then had to edit MyField so that the UNIT, or BLDG, or whatever had only these words and a unit number also only one word. So two words at the end of the test string separated by spaces. I selected only the strings in MyField that matched this last two word standard and then using Field Calculator (and the Python radio button where the original statement is listed in the String Function list) this is what I put in for MyField =

!MyField!.rsplit(' ', 2)[0]

And that worked. So still no idea how to express a wildcard in Find and Replace, but now I am able to match my addresses without the pesky UNITS, BLDGS, etc.

Have a great week everyone!

0 Kudos
BarryFosberg
New Contributor III

I hope this revives this old and never answered question.

1. Never mind what I am trying to do.

If editing an attribute table

What , if any are the wild cards that can be used in Find And Replace 

 

2. In general what are the wild cards that can be used in a calculate field for strings? For Number?

 

Since folks are rather concreate and  must have examples.

3.

A merge tool evident got corrupted and converted an address field from this

3594 CHERRY ST HOUSTON 77026

to

3594 CHERRY ST HOUSTON 770263594 CHERRY ST HOUSTON 77026 in every line of a 180K line table.

That is whatever the original address, it appears 2* in that field.

 

Because I can work with

3594 CHERRY ST 

I had hoped to replace every line with the text  Houston 77 and any and all text after it with nothing.

Find and Replace can find Houston 77, but * . % did not work as wild cards.

At least 7 variations in either Python or arcade using Split, or Replace , ran, but changed nothing in any line

example !USER_FullAddress!.replace("Houston 77.","")

!USER_FullAddress!.split("Houston 77.")[0]

$feature.USER_FullAddress(Replace"Houston 77%")[0]

all ran and changed nothing.

 

Suggestions please?

 

 

 

 

0 Kudos