Jump to content
ballouta

My Regex requires modifications to ignore blank lines

Recommended Posts

Hello

I spent literally 5 hours creating the following regex for a friend of mine!

(?s)(?=Configuration)(.*?)(?>onal\)\:)

The regex is supposed to capture several lines from a static content that starts with the word Configuration and ends with the word (optional):

This content has sometimes a new blank line and sometimes two empty lines.

Is it possible you kindly assist me in modifying the above regex so it extracts all the text needed, at the same time it ignores all new/blank lines?

Text Sample:

Hello

Configuration There is something here
s

bbye

optional):

Hoping for this output:

Hello

Configuration There is something here
s
bbye
optional):

We are using the function reg_match.

 

Thank you

Share this post


Link to post
Share on other sites

Regexes cannot modify the text that they capture. You'll need to find another method.

Share this post


Link to post
Share on other sites

Did you figure out a solution? One potential option, without regex, is to process the input line by line. Once you locate the line that starts with "Configuration", you can start ignoring lines that are blank. You would ignore lines that are blank until you reach the line that ends with "optional):". Then you would output the information as it is processed.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.