PDA

View Full Version : Remove all words after "=" character


ABC123

Rich Hartnett
04-27-2008, 07:08 PM
I have a table with a field which stores data like this:

03AF=Robbery, Firearm - Bank
03CD=Other Dangerous Weapon - Conv Store
04B=Assault - Knife Or Cutting Instrument
etc.

I want to set up a field rule (expression) that removes everything after the "=" character and just stores the coded portion (03AF) in a separate field.

I know this is probably simple, but I searched the message board and couldn't find anything similar.

MikeC
04-27-2008, 07:24 PM
Hi Rich,

How about


?EXTRACT_STRING("03AF=Robbery, Firearm - Bank","","=")
= "03AF"

you may have to add an alltrim() and also if there is a lot of text to search through and no special characters present there is an arguement for regex_safe to be set to true which speeds up the search.
http://support.alphasoftware.com/alphafivehelpv8/Functions/EXTRACT_STRING().htm

Stan Mathews
04-27-2008, 07:59 PM
I want to set up a field rule (expression) that removes everything after the "=" character and just stores the coded portion (03AF) in a separate field. Your calculated field expression could also be

word(otherfieldname,1,"=")

G Gabriel
04-27-2008, 08:01 PM
?word("03AF=Robbery, Firearm - Bank",1,"=")
= "03AF"

Rich Hartnett
04-27-2008, 09:51 PM
Thanks Stan, that simple formula works like a champ!