I'm having a problem with regexes.
The following code gives a compilation error. If I comment out
the regex outside of main and comment in the regex inside of main
then it does compile.
I'm using DMD v2.058
Any ideas what is going on?
--
import std.regex;
Regex!(char) testRegex = rege
On Wed, 28 Mar 2012 11:40:21 +0200, James Blewitt wrote:
I'm having a problem with regexes.
The following code gives a compilation error. If I comment out the
regex outside of main and comment in the regex inside of main then it
does compile.
I'm using DMD v2.058
Any ideas what is going
On 28.03.2012 13:40, James Blewitt wrote:
I'm having a problem with regexes.
The following code gives a compilation error. If I comment out the regex
outside of main and comment in the regex inside of main then it does
compile.
Please include compilation errors in future, it helps folks to figu
Cosider please the following:
string s1 = PREabcdPOST;
string s2 = PREabPOST;
string[] srar = ["ab", "abcd"];
// this can not be constructed with a particular order
foreach(sr; srar)
{
auto r = regex(sr; "g");
auto m = matchFirst(s1, r);
break;
// this one matches ab
// but I want t
On Thu, 07 Aug 2014 16:05:16 +, seany wrote:
> obviously there are ways like counting the match length, and then using
> the maximum length, instead of breaking as soon as a match is found.
>
> Are there any other better ways?
You're not really using regexes properly. You want to greedily m
On Thursday, 7 August 2014 at 16:05:17 UTC, seany wrote:
Cosider please the following:
string s1 = PREabcdPOST;
string s2 = PREabPOST;
string[] srar = ["ab", "abcd"];
// this can not be constructed with a particular order
foreach(sr; srar)
{
auto r = regex(sr; "g");
auto m = matchFirst(s
On Thursday, 7 August 2014 at 16:12:59 UTC, Justin Whear wrote:
On Thu, 07 Aug 2014 16:05:16 +, seany wrote:
obviously there are ways like counting the match length, and
then using
the maximum length, instead of breaking as soon as a match is
found.
Are there any other better ways?
You
On Thu, Aug 07, 2014 at 04:49:05PM +, seany via Digitalmars-d-learn wrote:
> On Thursday, 7 August 2014 at 16:12:59 UTC, Justin Whear wrote:
> >On Thu, 07 Aug 2014 16:05:16 +, seany wrote:
> >
> >>obviously there are ways like counting the match length, and then
> >>using the maximum length
On Thu, 07 Aug 2014 10:22:37 -0700, H. S. Teoh via Digitalmars-d-learn
wrote:
>
> So basically you have a file containing regex patterns, and you want to
> find the longest match among them?
> // Longer patterns match first patterns.sort!((a,b) => a.length >
> b.length);
>
> /
On Thu, Aug 07, 2014 at 05:33:42PM +, Justin Whear via Digitalmars-d-learn
wrote:
> On Thu, 07 Aug 2014 10:22:37 -0700, H. S. Teoh via Digitalmars-d-learn
> wrote:
>
> >
> > So basically you have a file containing regex patterns, and you want
> > to find the longest match among them?
>
> >
On Thu, Aug 07, 2014 at 10:42:13AM -0700, H. S. Teoh via Digitalmars-d-learn
wrote:
[...]
> Hmm, you're right. I was a bit disappointed to find out that the |
> operator in std.regex (and also in Perl's regex) doesn't do
> longest-match but first-match. :-( I had always thought it did
> longest-ma
On Thursday, 7 August 2014 at 18:16:11 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
https://issues.dlang.org/show_bug.cgi?id=13268
T
Thank you soo much!!
12 matches
Mail list logo