diff --git a/doc/ed.texi b/doc/ed.texi
index f654616..7f0ba6c 100644
--- a/doc/ed.texi
+++ b/doc/ed.texi
@@ -699,6 +699,8 @@ Matches any character not in a word.
 
 @end table
 
+In addition, as a GNU @command{ed} extension, if the regular
+expression starts with @samp{(?i)}, it is matched case-insensitively.
 
 @node Commands
 @chapter Commands
diff --git a/regex.c b/regex.c
index 3f88966..1c2d498 100644
--- a/regex.c
+++ b/regex.c
@@ -114,6 +114,7 @@ static regex_t * get_compiled_regex( const char ** const ibufpp,
   const char * pat;
   const char delimiter = **ibufpp;
   int n;
+  int re_flags = 0;
 
   if( delimiter == ' ' ) { set_error_msg( inv_pat_del ); return 0; }
   if( delimiter == '\n' || *++*ibufpp == delimiter ||
@@ -129,7 +130,13 @@ static regex_t * get_compiled_regex( const char ** const ibufpp,
   /* exp compiled && not copied */
   if( exp && exp != subst_regex_ ) regfree( exp );
   else exp = ( &store[0] != subst_regex_ ) ? &store[0] : &store[1];
-  n = regcomp( exp, pat, extended_regexp() ? REG_EXTENDED : 0 );
+  if( extended_regexp() ) re_flags |= REG_EXTENDED;
+  if( strncmp(pat, "(?i)", 4) == 0 )
+    {
+      re_flags |= REG_ICASE;
+      pat += 4;
+    }
+  n = regcomp( exp, pat, re_flags );
   if( n )
     {
     char buf[80];
