Pattern p = Pattern.compile( patternString ); Matcher m = p.matcher( obj1.toString( ) ); result = m.matches( );
else if ( pattern instanceof NativeRegExp ) { String testString = patternString.concat( ".test(\"" + obj1.toString( ) + "\")" ); Context cx = Context.enter( ); try { Scriptable scope = cx.initStandardObjects( ); Object rlt = evaluateJSScript( cx, scope, testString, "", 0 ); if ( rlt instanceof Boolean ) result = ( (Boolean) rlt ).booleanValue( ); } finally { Context.exit( ); } }
	private static boolean like( Object obj1, Object pattern ) throws DataException	{		if (obj1 == null || pattern == null) 		{		    if( obj1 == null && pattern == null)			    return true;			else			    return false;        }				boolean result = false;		try		{			String patternString = pattern.toString( );			// support '%' as SQL, replace all "%" with ".*"  			if ( patternString.indexOf( "%" ) >= 0 )			{				patternString = patternString.replaceAll( "\\Q%\\E", ".*" );			}						Pattern p = Pattern.compile( patternString );			Matcher m = p.matcher( obj1.toString( ) );			result = m.matches( );		}		catch ( RuntimeException e )		{			throw new DataException( ResourceConstants.MATCH_ERROR, e );		}		return result;	}