How to remove new line character/sentence in js

Hi team,
I have a test like this
I want to remove a characters in a sentence like
Shanti failed to
grasp the opportunity

Output:
Shanti failed to

I want to remove the second line.

@Gowthami_Doddavula

  1. Drag a “Read Text File” activity onto the workflow and configure it to read your input text file.
  2. Use an Assign activity to split the text into lines:
linesArray = yourTextInput.Split({Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
  1. Remove the second line from the array of lines:
linesArray.RemoveAt(1)
  1. Join the lines back into a single string:
modifiedText = String.Join(Environment.NewLine, linesArray)
  1. Use a “Write Text File” activity to write the modified string back to a file.
1 Like

Hi @Gowthami_Doddavula

Try this

inputText.Substring(0, inputText.IndexOf(vbLf))

Cheers!!

1 Like

Hi @Gowthami_Doddavula

You can try the split function to remove the first line in input String,

- Assign -> Input = "Shanti failed to
                     grasp the opportunity"
- Assign -> Output = Input.Split(Environment.NewLine.ToArray, StringSplitoptions.RemoveEmptyEntries).First

Check the below workflow for better understanding,

Hope it helps!!

1 Like