digitalmars.D.learn - tango -D2 regex
- seany (8/8) Dec 15 2013 I dont find any info on backtrack on tango-D2 regex.
- evilrat (4/13) Dec 15 2013 have you tried look the docs first?
- seany (10/13) Dec 16 2013 The only mention of backtrack is : bmatch
- Dmitry Olshansky (10/25) Dec 16 2013 Docs don't state anything like that. It finds _first_ match and returns
- JR (2/11) Dec 16 2013 Something like http://dpaste.dzfl.pl/0e02c3d1 ? Phobos though.
- Dmitry Olshansky (7/15) Dec 16 2013 With std.regex of Phobos this should just work.
- seany (3/23) Dec 17 2013 thanks! this is what i was looking for (the \1)
- John Colvin (3/12) Dec 16 2013 FYI if you know your regex at compile-time, the ctRegex in phobos
I dont find any info on backtrack on tango-D2 regex. For example, I want to match things like barFOObar or bazFOObaz so I would use, in PCRE, ^(\w*)FOO($1)$, with $1 meaning the word (given by \w* that was matced in the first subpattern (\w*) How to do the samein Tango for D2 (or even phobos for D2)?
Dec 15 2013
On Monday, 16 December 2013 at 07:46:30 UTC, seany wrote:I dont find any info on backtrack on tango-D2 regex. For example, I want to match things like barFOObar or bazFOObaz so I would use, in PCRE, ^(\w*)FOO($1)$, with $1 meaning the word (given by \w* that was matced in the first subpattern (\w*) How to do the samein Tango for D2 (or even phobos for D2)?have you tried look the docs first? phobos regex patterns described here http://dlang.org/phobos/std_regex.html
Dec 15 2013
On Monday, 16 December 2013 at 07:56:53 UTC, evilrat wrote:have you tried look the docs first? phobos regex patterns described here http://dlang.org/phobos/std_regex.htmlThe only mention of backtrack is : bmatch it returns a regex object with a machine state, and last match, but it is still not telling me how to actually do a backtrack match. I.e. if i know the machine state and a match (in my example, does that mean that foo is returned as a match or does it mean thatbaz /bar is returned as a match, and the next attempt will match the bar/baz - if not, then what is the call sequence? bmatch (match bar/baz) then match FOO, then again try to match what bmatch returned?)
Dec 16 2013
16-Dec-2013 12:06, seany пишет:On Monday, 16 December 2013 at 07:56:53 UTC, evilrat wrote:Docs don't state anything like that. It finds _first_ match and returns full state so that you may continue matching or just look at the current match. Backtracking is purely irrelevant technical detail.have you tried look the docs first? phobos regex patterns described here http://dlang.org/phobos/std_regex.htmlThe only mention of backtrack is : bmatch it returns a regex object with a machine state, and last match, but it is still not telling me how to actually do a backtrack match.I.e. if i know the machine state and a match (in my example, does that mean that foo is returned as a match or does it mean thatbaz /bar is returned as a match, and the next attempt will match the bar/baz - if not, then what is the call sequence? bmatch (match bar/baz) then match FOO, then again try to match what bmatch returned?)Simply put match/bmatch will return a range of matches as they are found in the input. Each match is, in turn, a random access range that contains full match, followed by each sub-match in the pattern. -- Dmitry Olshansky
Dec 16 2013
On Monday, 16 December 2013 at 07:46:30 UTC, seany wrote:I dont find any info on backtrack on tango-D2 regex. For example, I want to match things like barFOObar or bazFOObaz so I would use, in PCRE, ^(\w*)FOO($1)$, with $1 meaning the word (given by \w* that was matced in the first subpattern (\w*) How to do the samein Tango for D2 (or even phobos for D2)?Something like http://dpaste.dzfl.pl/0e02c3d1 ? Phobos though.
Dec 16 2013
16-Dec-2013 11:46, seany пишет:I dont find any info on backtrack on tango-D2 regex. For example, I want to match things like barFOObar or bazFOObaz so I would use, in PCRE, ^(\w*)FOO($1)$, with $1 meaning the word (given by \w* that was matced in the first subpattern (\w*)With std.regex of Phobos this should just work. auto re = regex(`^(\w*)FOO\1$`); assert("barFOObar".match(re)); Syntax is like in JavaScript or Perl.How to do the samein Tango for D2 (or even phobos for D2)?-- Dmitry Olshansky
Dec 16 2013
On Monday, 16 December 2013 at 17:20:59 UTC, Dmitry Olshansky wrote:16-Dec-2013 11:46, seany пишет:thanks! this is what i was looking for (the \1)I dont find any info on backtrack on tango-D2 regex. For example, I want to match things like barFOObar or bazFOObaz so I would use, in PCRE, ^(\w*)FOO($1)$, with $1 meaning the word (given by \w* that was matced in the first subpattern (\w*)With std.regex of Phobos this should just work. auto re = regex(`^(\w*)FOO\1$`); assert("barFOObar".match(re)); Syntax is like in JavaScript or Perl.How to do the samein Tango for D2 (or even phobos for D2)?
Dec 17 2013
On Monday, 16 December 2013 at 07:46:30 UTC, seany wrote:I dont find any info on backtrack on tango-D2 regex. For example, I want to match things like barFOObar or bazFOObaz so I would use, in PCRE, ^(\w*)FOO($1)$, with $1 meaning the word (given by \w* that was matced in the first subpattern (\w*) How to do the samein Tango for D2 (or even phobos for D2)?FYI if you know your regex at compile-time, the ctRegex in phobos is *very* fast.
Dec 16 2013