regex with literal (ie automatically replace '(' with '\(', etc) )

Diggory diggsey at googlemail.com
Thu May 30 01:14:53 PDT 2013


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
> simplified implementation and added missing escape symbols. Any 
> symbol
> missing?
> I was basing myself based on 
> 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 you can use the 
same escape sequences for both (\c -> c in the replacement 
string).


More information about the Digitalmars-d-learn mailing list