March 26, 2025Mar 26 Howdy all: I'm using this calculation to parse the department from a character string: Let ( db = District_Building__lxt ; If ( PatternCount ( db ; "Columbus Public - High School" ) or PatternCount ( db ; "ESU 7" ) or PatternCount ( db ; "Columbus Public - Kramer" ) ; Let ( [ len = Length ( db ) ; lastSpace = Position ( db ; "-" ; len ; -1 ) ] ; Right ( db ; len - lastSpace ) ) ) ) The calculation works, but curiously it inserts a character space at the beginning of the output of the calculation. How can i filter/calculate it out? Here are some samples of the text I'm using to parse from: Columbus Public - High School - Industrial Education ESU 7 - Learning Academy Columbus Public - Kramer Education Center
March 26, 2025Mar 26 49 minutes ago, 21st Century Man said: Where's the extra character space coming from? The space character is the character immediately after the last hyphen in the text. Suppose the text were just: "a - b". The length of this text is is 5, and the position of the hyphen is 3. 5 - 3 = 2, so your expression: Right ( db ; len - lastSpace ) will return the last two characters of the text, i.e. " b". 49 minutes ago, 21st Century Man said: How can i filter/calculate it out? It depends. If the hyphen separator is always followed by a space, you might simply subtract it: Right ( db ; len - lastSpace - 1 ) A better solution would look for the position of the entire separator pattern " - " (a hyphen surrounded by spaces) and do: Let ( [ len = Length ( db ) ; lastSeparator = Position ( db ; " - " ; len ; -1 ) ] ; Right ( db ; len - lastSeparator - 2 ) ) This would allow you to correctly extract "Carter-Brown" from "Smith - Jones - Carter-Brown". If you cannot be sure the space/s will always be there, you may use Trim() on the result (this is assuming the extracted portion will not contain any significant whitespace characters).
Create an account or sign in to comment