February 20, 2013 Re: Issues with std.regex | ||||
---|---|---|---|---|
| ||||
Posted in reply to jerro | 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. |
February 20, 2013 Re: Issues with std.regex | ||||
---|---|---|---|---|
| ||||
Posted in reply to MrAppleseed | Hello to everyone, and thank you for your help! Sorry for the delay in response, as I was busy with family matters. However, upon returning today, and with everyone's help, I have successfully gotten it to work. The code below worked out swimmingly: auto reg = regex(`[ 0-9a-zA-Z.*=+-;()"'\[\]<>,{}^#/\\]`); auto m = match(contents, reg); auto token = m.captures; Once again, thank you all for your help! :) |
Copyright © 1999-2021 by the D Language Foundation