Good evening everybody.
I would need to extract the first paragraph of a string, id est the part before the first couple of line returns (\n\n)
For example:
"We had wanted to leave at 20.
But we left at 22"
What I would like to get is "we had wanted to leave at 20".
I guess I have to use the two line feed, for I realized I sometimes put a space after the full stop, so that I guess I cannot use it...
I know I should use regex but that's still.beyond me.
Any hint?
Thank you, have a nice evening.
Getting first paragraph of a string
Moderator: Martin
- tsolignani
- Posts: 187
- Joined: 12 Jan 2019 11:53
- Location: Vignola, Mo, Italy
- Contact:
Re: Getting first paragraph of a string
You can use split to get the list of paragraphs.
or shorter:
Code: Select all
input = "Paragraph 1\n\nParagraph 2";
paragraphs = split(input, "\n\n");
first = paragraphs[0];
Code: Select all
input = "Paragraph 1\n\nParagraph 2";
first = split(input, "\n\n")[0];
Re: Getting first paragraph of a string
Why not (String) replace full stops with line feeds in the first instance? And/or (String) trim the leading/trailing space chars??"... for I realized I sometimes put a space after the full stop, ..."
- tsolignani
- Posts: 187
- Joined: 12 Jan 2019 11:53
- Location: Vignola, Mo, Italy
- Contact:
- tsolignani
- Posts: 187
- Joined: 12 Jan 2019 11:53
- Location: Vignola, Mo, Italy
- Contact: