gnu-regexp-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Regexp] gnu-regexp-1.1.4 question -- expert needed


From: RJocham72
Subject: [Regexp] gnu-regexp-1.1.4 question -- expert needed
Date: Mon, 03 Feb 2003 20:12:22 -0500

Hi All,
I am developing an open source tool called JCSC (http://jcsc.sourceforge.net) 
and I want to add an additional check on java source files. This check should 
check if the .java file has the correct header. In the case of JCSC each class 
has a FSF header. The regexp has been tested and seems to be ok but the code 
does not work.
I tried everything I could think about -- no success. Can an regexp expert
please have a look into that and tell me why this match does not match - Thanks!

Here the java code:

   static public void handleTypeHeader(StringBuffer pHeader, int pLine, int 
pColumn)
   {  
      String header = pHeader.toString();

      header = header.trim();
      sTypeHeaderRegexp = sTypeHeaderRegexp.trim();

      System.out.println("'" + header + "'");
      System.out.println("-----------------------------------");
      System.out.println("'" + sTypeHeaderRegexp + "'");
    
      if (sReguiresHeader)
      {
         if (! isRegexpMatch(sTypeHeaderRegexp, header))
         {
            addViolation(0, 0, "type does not have the correct header");
         }
      }
   }

    static boolean isRegexpMatch(Object regexp, Object value)
    {
        try
        { 
            RE reg = new RE(regexp.toString());
            
            if (reg.isMatch(value.toString()))
            {
                return true;
            }
        }
        catch (REException e)
        {
            e.printStackTrace();
        }

        return false;
    }    


and here the output - You can see the text and the regexp.

'/*
 * Copyright (C) 1999-2002 Ralph Jocham
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */'
-----------------------------------
'/\*
 \* Copyright \(C\) 1999-2002 Ralph Jocham
 \* This program is free software; you can redistribute it and/or
 \* modify it under the terms of the GNU General Public License
 \* as published by the Free Software Foundation; either version 2
 \* of the License, or \(at your option\) any later version\.
 \*
 \* This program is distributed in the hope that it will be useful,
 \* but WITHOUT ANY WARRANTY; without even the implied warranty of
 \* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE\.  See the
 \* GNU General Public License for more details\.
 \*
 \* You should have received a copy of the GNU General Public License
 \* along with this program; if not, write to the Free Software
 \* Foundation, Inc\., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 
USA\.
 \*/'

__________________________________________________________________
The NEW Netscape 7.0 browser is now available. Upgrade now! 
http://channels.netscape.com/ns/browsers/download.jsp 

Get your own FREE, personal Netscape Mail account today at 
http://webmail.netscape.com/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]