Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to use regex in python to catch patterns like keyword1 [arbitrary characters with a max length of 5] keyword2

How can I use re package to recognize a pattern as

keyword1 [arbitrary characters with a max length of 5] keyword2

For example, keyword1 abc keyword2 is valid, keyword1 a . keyword2 is also valid
but keyword1 1234abd keyword2 is not valid

Thank you

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

r"(?:keyword1).{5}(?:keyword2)

Checked this on https://regex101.com/

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading