jinglyhk
jinglyhk

Reputation: 13

Extract the first line of text in tableau

I need to extract the first line of text in tableau. I tried using Regex Replace function but I couldn't get the desired output.

Given below is the input.

Name:

ABC DEF LTD

GONZALEZ, Henry

Desired output:

ABC DEF LTD

What I tried: Regex_Replace('Column_name','

','')

Any help with this would be greatly appreciated.

Upvotes: 0

Views: 484

Answers (2)

Andy TAR Sols
Andy TAR Sols

Reputation: 1735

Try a non-regex approach. First convert the carriage return / line feed to a pipe (or some other symbol of your choosing. Your space may be CHAR(10) or could be CHAR(13)...or perhaps you have both. This example shows using CHAR(13):

[RemoveSpace]: replace([Name],CHAR(13),"|")

You want to keep the first line, so use this calc:

[KeepFirstLine]: SPLIT([RemoveSpace],"|",1)

Upvotes: 3

Per Ghosh
Per Ghosh

Reputation: 533

This should match first line with a at least one word character.

^.*\w+.*$
  • ^ start of line
  • .* any character except newline zero or more times
  • \w+ any word character one or more times
  • .* any character except newline zero or more times
  • $ end of line

Upvotes: 1

Related Questions