© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
26 replies
Quark

✅ Regex to capture all attributes of html tag but it capture the last only.

Hi,

i have this code (see the picture)

i don't understand why i have the last attribute only.

i need have all.
please, help me.

code to use:
 MatchCollection attrmatches = new Regex(@"<[a-zA-Z.]+(?:\s+(\w+)\s*=\s*""[^""]*"")*\s*>", RegexOptions.Compiled).Matches(line);
 MatchCollection attrmatches = new Regex(@"<[a-zA-Z.]+(?:\s+(\w+)\s*=\s*""[^""]*"")*\s*>", RegexOptions.Compiled).Matches(line);



thx
Capture_decran_2024-02-12_115820.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

multiple capture groups regex [Answered]
C#CC# / help
4y ago
❔ Regex expression to find the last occurrence in a string
C#CC# / help
4y ago
Create regex that returns the match only
C#CC# / help
4y ago
❔ how to change the size of all the objects with a tag?
C#CC# / help
4y ago