2

I want to use same variables in regexp pattern.

string Pattern = "<li.*?class=\".*?item\".*?>.*?<a.*?href=\"(?<link>.*?)\">(?<a1>.*?)>(?<title>.*?)(a1)";

e.g if there is "<span>" in a1 ,after the title variable the "<span>"should become.

0

1 Answer 1

1

If you need to reference a previously captured group

Use

\index//where index is the group number

OR

\k<name>//where name is the name of the group

So in your case it should be \k<a1>


Also regex is not used for parsing HTML

Use htmlagilitypack

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

2 Comments

\k<a1> k unrecognized escape sequence.
@alikoyuncu use it with @"\k<name>"..@ denotes a verbatim string which treat escape characters as literals..this happens cuz \ before any character is treated as a special character..so you need to escape that check with @

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.