• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

how to find last word(<=8 characters) of each paragraph?

Explorer ,
Aug 19, 2022 Aug 19, 2022

Copy link to clipboard

Copied

I need to find last word of each paragraph. Also check lastword is <= 8 characters only( include special character, dot and numbers). Find and apply no break condition.


for example.

Common (may affect up to 1 in 10 pat):
- Severe kidney failure (this will be ascertained by your doctor through some specific blood test)
- Low levels of calcium in the blood.
Uncommon (may affect up to 1 in 100 patients):
how many mg of each tablet is in a bottle?
Each tablet contains 100 mg.
If you enter number of paragraphs or lines higher than 200 –the function will work but will produce only 200 paragraphs (10).

TOPICS
Scripting

Views

825

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 22, 2022 Aug 22, 2022

If you don't want to include closing punctuation in the character count of the last word I would add [[:punct:]]* which will find any punctuation if it exists (* is the zero or more times match), and maybe add \s* as well in case the original text has extraneous trailing whitespace, so the final code would look like

\s\K\S{1,8}[[:punct:]]*\s*$

 This would still fail if there is whitespace before any ending punctuation.

Votes

Translate

Translate
Explorer ,
Aug 23, 2022 Aug 23, 2022

Copy link to clipboard

Copied

LATEST

Hi Peter Spier & Peter Kahrel,

 

Thanks for your help, now everything is working fine.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines