Case insensitive regexp

494 views
Skip to first unread message

Lauri Oherd

unread,
Oct 5, 2008, 10:55:37 AM10/5/08
to Clojure
How can I make regexp case insensitive?
Should I use function clojure/re-pattern for that by passing it a
second argument "Pattern.CASE_INSENSITIVE" (as described in
http://www.regular-expressions.info/java.html)?

Btw I noticed that function clojure/find-doc is currently also case
sensitive:

user=> (find-doc "prints") ; returns only one function
-------------------------
clojure/time
([expr])
Macro
Evaluates expr and prints the time it took. Returns the value of
expr.
nil

user=> (find-doc "documentation for") ; .. although there are more of
them
-------------------------
clojure/doc
([name])
Macro
Prints documentation for a var or special form given its name
-------------------------
clojure/find-doc
([re-string])
Prints documentation for any var whose documentation or name
contains a match for re-string
nil

Thanks,
Lauri

Randall R Schulz

unread,
Oct 5, 2008, 11:57:40 AM10/5/08
to clo...@googlegroups.com
On Sunday 05 October 2008 07:55, Lauri Oherd wrote:
> How can I make regexp case insensitive?

One way is to use the option-control syntax of the source-level regular
expression notation itself:

This is excerpted from the JavaDocs for java.util.regex.Pattern at
<http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html>:

-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
Special constructs (non-capturing)
...
(?idmsux-idmsux) Nothing, but turns match flags i d m s u x on - off
(?idmsux-idmsux:X) X, as a non-capturing group with the given flags
i d m s u x on - off
...
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-


> ...
>
> Thanks,
> Lauri


Randall Schulz

Reply all
Reply to author
Forward
0 new messages