Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have hopefully a very straightforward question that I just can't resolved. I have a particular field that displays data in the format "John Test TT - RRR" etc. I want it to be simply displayed as "John Test" so require " TT - RRR" to be removed. I've tried a range of string functions but haven't been able to get the correct answer. Thanks in advance,
Ralph
Either put the whole thing inside trim() function - it removes leading and trainling spaces, or modify the expression a little by adding -1:
left('John Test TT - RRR', index('John Test TT - RRR', ' ', 2)-1)
Try SubField([your string], ' TT', 1)
Sorry I should have made clear that "TT" and "RRR" can be different values and the RRR value can change in length (usually 2, 3 or 4 characters). Thanks
Ralph,
That means the the question is about the rules. Does it mean you need to remove the part of the string staring from the 2nd space?
Regards,
Michael
Michael,
Yes anything starting from the 2nd space should be purged from the string.
Thanks,
Ralph
Try this:
left('John Test TT - RRR', index('John Test TT - RRR', ' ', 2))
Edit: If the name can be more than two words (John Lesley Test), you can count spaces from the end, assuming there are three:
left(Field, index(Field, ' ', -3))
Yes that works brilliant. Many thanks,
Ralph
Sorry just noticed one further thing with the below, there is a space after the name, e.g. "John Test ", how can I make it simply "John Test" with no space after Test?
Thanks again,
Ralph
Either put the whole thing inside trim() function - it removes leading and trainling spaces, or modify the expression a little by adding -1:
left('John Test TT - RRR', index('John Test TT - RRR', ' ', 2)-1)
Works great, thanks again.