Subscribe to this thread
Home - General / All posts - StringTrimEnd - transform expression issue
Graeme

995 post(s)
#17-Nov-23 00:08

I Have a table of addresses and wish to delete everything after the first comma for each record. Using Transform / Expression I write

StringTrimEnd([STREET_ADDRESS], ',')

but no change seems to be made. I'm guessing the syntax is broadly OK as the preview works (great feature) - see screenshot. In 8 I would add "," to the tool properties token list and transform "Delete Last Token" and clean up the remaining commas using edit / replace.

9.0.181, W10

Attachments:
StringTrimEnd issue.JPG

Dimitri


7,505 post(s)
#17-Nov-23 06:27

wish to delete everything after the first comma for each record

Ah, but that's not what StringTrimEnd does. To refresh:

Given a string and a trim string, removes all occurrences, including repeated occurrences, of the trim string at the endof the string and returns the trimmed string. Often used with a trim string of just one character, a ' ' space character, to trim extra spaces from the end of a string. Often used to trim other text as well.

Using a single comma as a trim string will trim that comma only if it is the last character in the string to be trimmed (the "target" string). If there is an invisible space character at the end of the target string, nothing will be trimmed, and likewise if one or more commas appear anywhere in the target string other than the very end.

An example, using ',' as the trim string:

You can accomplish what you want by replacing a regular expression that picks out everything after the first comma with an empty replacement.

See this topic or, reducing to what's left as in this topic.

Attachments:
stringtrim.png

Graeme

995 post(s)
#17-Nov-23 07:32

Thank you, as always, for pointing me in the right direction!

Sloots

697 post(s)
#17-Nov-23 08:27

This solution avoids the use of regular expressions.

--SQL9

StringSubstringLen(

 [address],

 0

 , StringFind([address]',')

)


http://www.mppng.nl/manifold/pointlabeler

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.