AnsweredAssumed Answered

Searching field with upper or lower case

Question asked by CCweedcontrol on Nov 5, 2015
Latest reply on Nov 5, 2015 by dkwiens

I have a script that works good but only if the first letter of the input has the first letter upper case.

Currently every road name starts with an upper case letter. How can I format the expression to allow for either upper or lower case inputs.

 

 

Thanks.

 

import arcpy  
arcpy.AddMessage("Starting")  
pu = arcpy.GetParameterAsText(0)  
arcpy.AddMessage(pu)  
mxd = arcpy.mapping.MapDocument("CURRENT")  
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]  
lyr = arcpy.mapping.ListLayers(mxd, "Roads", df)[0]

pu = arcpy.GetParameterAsText(0) 
arcpy.AddMessage(lyr.name)  
expression = "FENAME LIKE '%{}%'".format(pu) 
arcpy.AddMessage(expression)  
arcpy.SelectLayerByAttribute_management(lyr,"NEW_SELECTION",expression)  
df.extent = lyr.getSelectedExtent()  

arcpy.RefreshActiveView()  
arcpy.AddMessage("Completed")  

Outcomes