• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Match header and values, mutliline using regex

Resolved: Match header and values, mutliline using regex

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I have a document with the following structure:
  • A header (some text without any whitespace in the same line)
  • A list (could be empty) of values:
  • Each value starts with a tab character, and then is text without any whitespaces.

I would like to build a regex pattern such that each match contains 1 header group and 0-n values group.
Here is what I am trying, which I believe it is quite close, but probably some small problem I can’t find:
https://regex101.com/r/XSszya/1
Thanks.

Answer:

You can repeat the second part starting with a newline and a tab.
Then repeat the inner part of the value group in its own non capture group to get the whole match in group value
Regex demo

If you have better answer, please add a comment about this, thank you!

matching python regex string
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How to make statement case insensitive when uploading a dta file with specified columns?

27/03/2023

Resolved: Sort dataframe columns value by close it to another column

27/03/2023

Resolved: PostgreSQL resample 1 minute OHLCV candle data into 5 minute OHLCV candle data

27/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.