|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.ide digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
digitalmars.D.learn - hyperlink regular expression pattern
I want to split an HTML anchor tag into its constituent parts. I have a regular
expression pattern that works with .NET's Regex class, but not with std.regexp
- it errors out with "*+? not allowed in atom". I think this means something in
the pattern is non-standard.
Here's my code:
if (auto m = std.regexp.search(
"<a href=\"www.google.com\">Google</a>",
r"<a.*?href=[""'](?<url>.*?)[""'].*?>(?<name>.*?)</a>")) {
string url = m.match(1);
string name = m.match(2);
}
The problematic parts are "?<url>" and "?<name>" - but not being a whiz with
regular expressions, I don't know what to use instead.
Perhaps someone's got a better pattern they could post?
John.
May 09 2008
Perhaps someone's got a better pattern they could post? May 09 2008
novice2 Wrote:Perhaps someone's got a better pattern they could post? May 09 2008
John C Wrote:Thanks - that seems to extract the href and text. May 09 2008
|