Issues with std.regex

MrAppleseed email at email.com
Wed Feb 20 14:09:44 PST 2013


On Saturday, 16 February 2013 at 21:58:23 UTC, jerro wrote:
>> Pattern with error: `[ 0-9a-zA-Z.*=+-;()"'\[\]<>,{}^#/\]` 
>> <--HERE-- ``
>
> The problem here is that you have \ right before the ] at the 
> end of the string. Because it is preceeded by \, ] is 
> interpretted as a character you are matching on, not as a 
> closing bracket for the initial [. If you want to match \ you 
> need this:
>
> [ 0-9a-zA-Z.*=+-;()"'\[\]<>,{}^#/\\]

Sorry for the delay in response,

As you can read in the original post, I have tried the 
suggestions in both of your comments (couldn't figure out how to 
reply to both, unfortunately). Both of which caused errors. The 
code you suggested is one of the first I tried,(

auto reg = regex("[ 0-9a-zA-Z.*=+-;()\"\'\[\]<>,{}^#/\\]");

), yet I still got that error. I believe that the regex engine 
changed the "\\" into a single backslash "\" which is displayed 
in the error you quoted.


More information about the Digitalmars-d-learn mailing list