digitalmars.D.learn - Using regex to "sort" its matches
- Linden Krouse (8/8) Apr 16 2013 Is there a way to use the regex library to put matches of
- Dmitry Olshansky (18/26) Apr 16 2013 For that particular case you can as well use this pattern:
- Linden Krouse (3/36) Apr 16 2013 Nice, that work well for what I'm trying to do when it gets
Is there a way to use the regex library to put matches of different regexs or classes into different slices? For instance, could I use them to match a string at the same time and stop if the first one is found and keep their results separate (as if the little new to regexs for the record.
Apr 16 2013
16-Apr-2013 22:59, Linden Krouse пишет:Is there a way to use the regex library to put matches of different regexs or classes into different slices? For instance, if I had the match a string at the same time and stop if the first one is found and keep their results separate (as if the regex was different one for "(?<=%)\w+\b" ). I'm a little new to regexs for the record.For that particular case you can as well use this pattern: and then check what character is the last one before your match by hand: //put in one place else if(m.pre.back == '%') // put somewhere else } More general interface to do it is being discussed recently, in essence it gives you ability to switch over a bunch of regular expressions. See: https://github.com/D-Programming-Language/phobos/pull/1241 The machinery to efficiently combine regular expressions like that will come sometime later but the interface should stay the same. -- Dmitry Olshansky
Apr 16 2013
On Tuesday, 16 April 2013 at 20:00:37 UTC, Dmitry Olshansky wrote:16-Apr-2013 22:59, Linden Krouse пишет:Nice, that work well for what I'm trying to do when it gets added. ThanksIs there a way to use the regex library to put matches of different regexs or classes into different slices? For instance, if I had the use them to match a string at the same time and stop if the first one is found and keep their results separate (as if the regex was and a different one for "(?<=%)\w+\b" ). I'm a little new to regexs for the record.For that particular case you can as well use this pattern: and then check what character is the last one before your match by hand: //put in one place else if(m.pre.back == '%') // put somewhere else } More general interface to do it is being discussed recently, in essence it gives you ability to switch over a bunch of regular expressions. See: https://github.com/D-Programming-Language/phobos/pull/1241 The machinery to efficiently combine regular expressions like that will come sometime later but the interface should stay the same.
Apr 16 2013