locked
Trying to extract first sentence of a statement in a multi-line test field RRS feed

  • Question

  • I am trying to extract the first sentence of a statement in a multi-line text field.  I have set up the workflow to pull the first 100 characters, BUT I would like to be able to pull the first sentence out in it's entirety.  Problem I have is the first sentence will very rarely be the same length.

    Is there a formulae that will let me do this?

    I don't want to add a title field to have someone clarify the statement made in the other column.

    Monday, January 20, 2014 1:20 PM

Answers

  • Hi Robert,

    Here is some c# if you are using Visual Studio for your workflow.

    Assuming the varable "str" contains the string of the sentences in the milti-line field

    you should be looking for the first occurance of the chars (period followed by a space) ". " this will give you the location of the first instance of ". "

    then do a substring starting with the first char all the way to the location of the first instance of the chars ". "

    the substing will get rid of anything after the first sentence.

     string str;
                
    str = "str. 1gr. g";
    str = str.Substring(0, str.IndexOf(". ")+1);

    You can also use a calculated column to get the first sentence using this equation.

    =LEFT([your multi-line field],FIND(". ",[your multi-line field],1))

    Here is an even better calculation if you go the calculated column route.

    =IF(ISNUMBER(FIND(". ",[Your multi-line field],1))=TRUE,LEFT([Your multi-line field],FIND(". ",[Your multi-line field],1)),LEFT([Your multi-line field],255))

    Alex







    • Edited by Alex Hornak Monday, January 20, 2014 3:46 PM
    • Marked as answer by Victoria Xia Wednesday, February 5, 2014 9:27 AM
    Monday, January 20, 2014 2:18 PM