Regex in D capturing too much -
I am writing a function that is designed to take a text like this:
%% HEADER foo bar baz %% BODY foo baz baz and return an array like this:
{"foo bar baz" Keeping this in mind, I wrote the following: string [2] different hedgehog (string input) {string [2] different; auto header = matchfirst (input , Regedx (r "%% header \ n ((| | | \ n) *) \ n %% body", "g"); if (header.mpt) {new parserer expiation ("no Found %% header. ");} Different from Else {[0] = header.front (); Auto BD = MatchFirst (Input, Reggae (R" %% body \ n ((| | \ n) *) "," G ")); If (bdy.empty ()) {New Parser throwing exception (" No% BDI found. ");} And (separate [1] = bdy.front ();}} Returns in;} However, when I try to experiment with the following input:
"%% HEADER \ nfoo bar game \ N% body body \ nfoo first capture "%% HEADER \ nfoo barfish \ n %% body \ , which is obviously very high. Am I using > Std.regex What do I want wrongly?
The first element ( front ) is a complete group, your pattern Is from the first letter to the last. After this the first time is stored, i.e. the first bracket section. Then, instead of code> [1] instead of front . Or popFront is complete match away so that front is the first robber.
Comments
Post a Comment