Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

regex - How can I match XML tags and attributes with a regular expression in Perl?

What I need is something like this:

/<[wd]+ ([wd]+=[wd])+/>/

Something that would match several attribute key/value pairs. Is that possible?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You'll have much more succes using an XML parser, for example, XML::Parser. Parsing XML using regular expressions is very difficult (impossible?) and unless your use case is trivial, a proper XML parser is the reliable solution.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...