0

I am trying replace some content in a tex file, example bellow.

I would like to match the content from \starttable till second \HL.

\starttable[|lp(0.08\textwidth)|lp(0.35\textwidth)|lp(0.48\textwidth)|lp(0.08\textwidth)|]
\HL
\NC Req. Id
\NC Description
\NC Test Scenario
\NC Result
\NC\AR
\HL
\NC TAF-89

\NC Trigger test start - from jig

\NC 
\NC Unavailable

\NC\AR
\NC TAF-88

\NC Trigger test start - using scanner

\NC 
\NC Unavailable

\NC\AR
\HL

I tried with

Regex tableHeaderRegex = new Regex(@"(\\starttable(.*))(\\HL..(\\NC.*)+\\HL)",
                                 RegexOptions.Singleline);

But this does not stop at the second \HL, but goes on to match the last \HL because of \\NC.*

I have also tried the RegexOptions.Multiline but with no success.

1 Answer 1

1
\\starttable[\s\S]*?\\HL[\s\S]*?\\HL

You can use this without g flag to attain the same.See demo.

https://regex101.com/r/vN3sH3/41

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.