Is there a way to remove a specific character from a string in ArcGIS

2006
13
03-06-2018 02:31 AM
Adil_Toorawa
New Contributor II

Hi,

I have a list as follows;

Object ID        Field 1

1                     Example,Example

2                     ,Example,Example,Example

3                     ,Example

I want to remove just the first comma.

I would appreciate your assistance.

13 Replies
DanPatterson_Retired
MVP Esteemed Contributor

To be completely inclusive

txt = "!A simple question becomes a Monty Python Circus"

['Good','Grief!!!'][txt[0] in '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~']

'Grief!!'
BryanL
by
New Contributor

Hi All,

I have a somewhat similar question that I have problem solving

Object ID        Field

1                     Apple.

2                     Orange.

3                     Egg

I would like to remove the trailing "." if any. However my code below simply check the string and remove all last characters.

Trim(Left([Field], LEN([Field])-1))

Appreciate any help.

Cheers

0 Kudos
PeteCrosier
Occasional Contributor III

Easiest way is probably using a Python expression, something like !field!.rstrip(".")

TedKowal
Regular Contributor II

IF right([Field],1) = "." then

   [Field] = Trim(Left([Field],LEN([Field])-1))

ELSE

   [Field]=Trim([Field])

END IF

0 Kudos