Closed Keyamoon closed 6 years ago
@Keyamoon Currently that is not supported. The library compiles its own regex and it does this to control the fact that the regex only has to match the beginning of the input.
The result is that simply passing in a Regex
that is case insensitive is not an option, because the package will lose the control it needs. The current workaround is to use the regex
function in this package with regexes having case insensitive character classes. For example: [A-Za-z]
or [A-z]
.
The string
is case sensitive by design. Using an or
(or (string "foo") (string "FOO")
) or choice
may help you in this.
Does this work for you?
Otherwise, can you state what you try to achieve with and provide a real example?
I think you meant to say that string
is case sensitive by design.
I'm trying to parse an HTML doctype declaration. I'm currently using an or
for parsing "doctype" or "DOCTYPE", but something like "docTyPe" would be valid too.
Just realized I could use [dD][oO][cC][tT][yY][pP][eE]
too.
Yes I meant to say sensitive.
The 'ugly' but working solution for now would be a regex that matches each char case insensitive:
(d|D)(o|O)(c|C) ...
But this is suboptimal.
Adding one or two new functions would be an option regexWithOptions
and/or caseInsensitiveString
, but I would like more feedback from other people before adding these parsers.
@Keyamoon When you only encounter this in the doctype string, I think this is a good workaround.
In addition: Maybe look into elm-xml. This library may contain what you are trying to do.
Yeah, it's a good workaround for now. Thank you.
It's definitely better to get more feedback before jumping to conclusion and adding new functions.
I'll leave the issue open for now. I'll check back in after a while.
Will close due to inactivity
Perhaps I'm missing something, but I didn't find any way to make a case insensitive string/regex parser.