0

I would like to remove N_A and N123#N123 from my Labels. How do I do that?

So far:

str([RTN]).replace('N_A',' ')

I still Need to remove the eg. N123#N123 as well from the Labels, but keeping the single eg. N123 Labels.

Attribut Tabel: N_A to be removed N123#N123 to be removed N123 must not be removed N321 must not be removed

closed as unclear what you're asking by neogeomat, whyzar, Dan C, Vince, aldo_tapia Apr 30 '18 at 14:59

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

1

It is a bit unclear what you want. Can 123 in N123 be any number with three digits? If not try:

Expression:

def FindLabel ( [Label]  ):
  a = [Label]
  a = a.replace('N_A','')
  if a.count('N123')>1:
    a = a.replace('N123','')
  return a

Change Label to match the name of your field

enter image description here

If it can be N+any three digits:

def FindLabel ( [Label]  ):
  import re
  p = re.compile("[N]\d{3}")
  a = [Label]
  a = a.replace('N_A','')
  if len(re.findall(p,a))>1:
    a = re.sub(p,'',a)
  return a
1

If you want to replace any instance of N_A and N123#N123

you may use this label expression using the python parser option::

[RTN].replace('N_A','').replace('N123#N123','')

Not the answer you're looking for? Browse other questions tagged or ask your own question.