regex with literal (ie automatically replace '(' with '\(', etc) )
Timothee Cour
thelastmammoth at gmail.com
Thu May 30 03:24:10 PDT 2013
> According to this: http://dlang.org/phobos/std_**regex.html#.replace<http://dlang.org/phobos/std_regex.html#.replace> you
can use the same escape sequences for both (\c -> c in the replacement
string).
Your suggestion does not work; try for yourself by replacing the $$ by \$
in my code. Is that a bug in std.regex' doc?
eg:
replace("",regex(``),`\$`);
=> invalid format string in regex replace
However everything works fine with $$, see my code above.
On Thu, May 30, 2013 at 1:14 AM, Diggory <diggsey at googlemail.com> wrote:
> On Thursday, 30 May 2013 at 06:50:06 UTC, Timothee Cour wrote:
>
>> ok, here it is:
>>
>> https://github.com/**timotheecour/dtools/blob/**
>> master/dtools/util/util.d#L78<https://github.com/timotheecour/dtools/blob/master/dtools/util/util.d#L78>
>> simplified implementation and added missing escape symbols. Any symbol
>> missing?
>> I was basing myself based on http://dlang.org/phobos/std_**regex.html<http://dlang.org/phobos/std_regex.html>,
>> table
>> entry '\c where c is one of', but that was incomplete. I'm also noting
>> that
>> table entry 'any character except' is also incomplete.
>>
>> Technically any working "escapeRegex" would also function as a valid
>>>
>> "escapeRegexReplace", although it might be slightly faster to have a
>> specialised one.
>>
>> not sure, because they escape differently (\$ vs $$).
>>
>
> According to this: http://dlang.org/phobos/std_**regex.html#.replace<http://dlang.org/phobos/std_regex.html#.replace>you can use the same escape sequences for both (\c -> c in the replacement
> string).
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20130530/97a66e57/attachment.html>
More information about the Digitalmars-d-learn
mailing list