Example usage for java.util.regex Pattern DOTALL

List of usage examples for java.util.regex Pattern DOTALL

Introduction

In this page you can find the example usage for java.util.regex Pattern DOTALL.

Prototype

int DOTALL

To view the source code for java.util.regex Pattern DOTALL.

Click Source Link

Document

Enables dotall mode.

Usage

From source file:org.craftercms.profile.services.ProfileServiceIT.java

@Test
public void testCreateAndVerifyProfile() throws Exception {
    GreenMail mailServer = new GreenMail(ServerSetupTest.SMTP);
    mailServer.start();/*w ww. ja  v a 2s .c  o  m*/

    tenantService.verifyNewProfiles(DEFAULT_TENANT, true);

    Profile profile = profileService.createProfile(DEFAULT_TENANT, AVASQUEZ_USERNAME, AVASQUEZ_PASSWORD1,
            AVASQUEZ_EMAIL1, true, AVASQUEZ_ROLES1, null, VERIFICATION_URL);

    try {
        assertNotNull(profile);
        assertNotNull(profile.getId());
        assertEquals(AVASQUEZ_USERNAME, profile.getUsername());
        assertNull(profile.getPassword());
        assertEquals(AVASQUEZ_EMAIL1, profile.getEmail());
        assertFalse(profile.isVerified());
        assertFalse(profile.isEnabled());
        assertNotNull(profile.getCreatedOn());
        assertNotNull(profile.getLastModified());
        assertEquals(DEFAULT_TENANT, profile.getTenant());
        assertEquals(AVASQUEZ_ROLES1, profile.getRoles());
        assertNotNull(profile.getAttributes());
        assertEquals(0, profile.getAttributes().size());

        // Wait a few seconds so that the email can be sent
        Thread.sleep(3000);

        String email = GreenMailUtil.getBody(mailServer.getReceivedMessages()[0]);

        assertNotNull(email);

        Pattern emailPattern = Pattern.compile(VERIFICATION_EMAIL_REGEX, Pattern.DOTALL);
        Matcher emailMatcher = emailPattern.matcher(email);

        assertTrue(emailMatcher.matches());

        String verificationTokenId = emailMatcher.group(1);

        Profile verifiedProfile = profileService.verifyProfile(verificationTokenId);

        assertNotNull(verifiedProfile);
        assertEquals(profile.getId(), verifiedProfile.getId());
        assertTrue(verifiedProfile.isEnabled());
        assertTrue(verifiedProfile.isVerified());
    } finally {
        profileService.deleteProfile(profile.getId().toString());

        tenantService.verifyNewProfiles(DEFAULT_TENANT, false);

        mailServer.stop();
    }
}

From source file:com.xebia.incubator.xebium.ExtendedSeleniumCommand.java

private Pattern globToRegExp(String glob) {
    return Pattern.compile("^\\Q" + glob.replace("*", "\\E.*\\Q").replace("?", "\\E.\\Q") + "\\E$",
            Pattern.DOTALL);
}

From source file:org.ms123.common.libhelper.Utils.java

private static Object[] getLineNumberFromMsg(String msg) {
    try {/*from w w  w  .j  a v a 2s.  c  o  m*/
        Pattern p = Pattern.compile(".*Script\\d{1,5}.groovy: (\\d{1,5}):(.*)", Pattern.DOTALL);
        Matcher m = p.matcher(msg);
        Object[] ret = new Object[2];
        if (m.find()) {
            ret[0] = m.group(1);
            ret[1] = m.group(2);
            return ret;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.LoadGeneExpressionDataListener.java

@Override
public void handleEvent(Event event) {
    this.topNode = this.loadDataUI.getTopNode();
    this.path = this.dataType.getPath().getAbsolutePath();
    this.sortName = this.dataType.getStudy().getPath().getParentFile().getAbsolutePath() + File.separator
            + ".sort";
    loadDataUI.openLoadingShell();//from ww  w .ja va 2 s  .  c o  m
    new Thread() {
        public void run() {
            try {
                String[] splited = topNode.split("\\\\", -1);
                if (splited[0].compareTo("") != 0) {
                    loadDataUI.setMessage("A study node has to begin by the character '\\'");
                    loadDataUI.setIsLoading(false);
                    return;
                }
                try {
                    Class.forName("oracle.jdbc.driver.OracleDriver");
                    String connectionString = "jdbc:oracle:thin:@" + PreferencesHandler.getDbServer() + ":"
                            + PreferencesHandler.getDbPort() + ":" + PreferencesHandler.getDbName();

                    Connection con = DriverManager.getConnection(connectionString,
                            PreferencesHandler.getMetadataUser(), PreferencesHandler.getMetadataPwd());
                    Statement stmt = con.createStatement();
                    ResultSet rs = stmt
                            .executeQuery("select * from table_access where c_name='" + splited[1] + "'");
                    if (!rs.next()) {//have to add a top node
                        stmt.executeQuery("insert into table_access(" + "c_table_cd," + "c_table_name,"
                                + "c_protected_access," + "c_hlevel," + "c_fullname," + "c_name,"
                                + "c_synonym_cd," + "c_visualattributes," + "c_totalnum," + "c_facttablecolumn,"
                                + "c_dimtablename," + "c_columnname," + "c_columndatatype," + "c_operator,"
                                + "c_dimcode," + "c_tooltip," + "c_status_cd) values(" + "'" + splited[1] + "',"
                                + "'i2b2'," + "'N'," + "0," + "'\\" + splited[1] + "\\'," + "'" + splited[1]
                                + "'," + "'N'," + "'CA'," + "0," + "'concept_cd'," + "'concept_dimension',"
                                + "'concept_path'," + "'T'," + "'LIKE'," + "'\\" + splited[1] + "\\'," + "'\\"
                                + splited[1] + "\\'," + "'A')");
                        stmt.executeQuery("insert into i2b2 values(0, '\\" + splited[1] + "\\', '" + splited[1]
                                + "','N','CA',0,null, null, 'CONCEPT_CD','CONCEPT_DIMENSION','CONCEPT_PATH', 'T', 'LIKE','\\"
                                + splited[1] + "\\', null, '\\" + splited[1]
                                + "\\', sysdate, null, null, null, null, null, '@', null, null, null)");
                    }
                    con.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                    loadDataUI.displayMessage("SQL error: " + e.getLocalizedMessage());
                    loadDataUI.setIsLoading(false);
                    return;
                } catch (ClassNotFoundException e) {
                    loadDataUI.displayMessage("Java error: Class not found exception");
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    loadDataUI.setIsLoading(false);
                    return;
                }
                //initiate kettle environment
                KettleEnvironment.init(false);

                //find the kettle job to initiate the loading
                URL jobUrl = new URL(
                        "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/load_gene_expression_data.kjb");
                jobUrl = FileLocator.toFileURL(jobUrl);
                String jobPath = jobUrl.getPath();
                //create a new job from the kettle file
                JobMeta jobMeta = new JobMeta(jobPath, null);
                Job job = new Job(null, jobMeta);

                //find the other files needed for this job and put them in the cache
                jobUrl = new URL(
                        "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/validate_gene_expression_params.ktr");
                jobUrl = FileLocator.toFileURL(jobUrl);
                jobUrl = new URL(
                        "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/validate_gene_expression_columns.ktr");
                jobUrl = FileLocator.toFileURL(jobUrl);
                jobUrl = new URL(
                        "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/check_gene_expression_filenames.ktr");
                jobUrl = FileLocator.toFileURL(jobUrl);
                jobUrl = new URL(
                        "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/load_all_gene_expression_files_for_study.kjb");
                jobUrl = FileLocator.toFileURL(jobUrl);
                jobUrl = new URL(
                        "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/run_i2b2_process_mrna_data.ktr");
                jobUrl = FileLocator.toFileURL(jobUrl);
                jobUrl = new URL(
                        "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/load_subject_sample_map_to_lt.ktr");
                jobUrl = FileLocator.toFileURL(jobUrl);
                jobUrl = new URL(
                        "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/get_list_of_gene_expression_filenames.ktr");
                jobUrl = FileLocator.toFileURL(jobUrl);
                jobUrl = new URL(
                        "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/load_gene_expression_one_study.kjb");
                jobUrl = FileLocator.toFileURL(jobUrl);
                jobUrl = new URL(
                        "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/set_gene_expression_filename.ktr");
                jobUrl = FileLocator.toFileURL(jobUrl);
                jobUrl = new URL(
                        "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/validate_gene_expression_columns.ktr");
                jobUrl = FileLocator.toFileURL(jobUrl);
                jobUrl = new URL(
                        "platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/load_gene_expression_data_to_lz.ktr");
                jobUrl = FileLocator.toFileURL(jobUrl);
                jobUrl = new URL("platform:/plugin/fr.sanofi.fcl4transmart/jobs_kettle/pivot_gene_file.ktr");
                jobUrl = FileLocator.toFileURL(jobUrl);

                job.getJobMeta().setParameterValue("DATA_FILE_PREFIX",
                        ((GeneExpressionData) dataType).getRawFile().getName());

                job.getJobMeta().setParameterValue("DATA_LOCATION", path);
                job.getJobMeta().setParameterValue("MAP_FILENAME",
                        ((GeneExpressionData) dataType).getStsmf().getName());
                job.getJobMeta().setParameterValue("DATA_TYPE", "R");

                job.getJobMeta().setParameterValue("FilePivot_LOCATION", "");

                job.getJobMeta().setParameterValue("LOAD_TYPE", "I");
                job.getJobMeta().setParameterValue("LOG_BASE", "2");
                job.getJobMeta().setParameterValue("SAMPLE_REMAP_FILENAME", "NOSAMPLEREMAP");
                job.getJobMeta().setParameterValue("SAMPLE_SUFFIX", ".rma-Signal");
                job.getJobMeta().setParameterValue("SECURITY_REQUIRED", "N");
                job.getJobMeta().setParameterValue("SOURCE_CD", "STD");

                File sort = new File(sortName);
                if (!sort.exists()) {
                    FileUtils.forceMkdir(sort);
                }
                path = sort.getAbsolutePath();
                job.getJobMeta().setParameterValue("SORT_DIR", path);

                job.getJobMeta().setParameterValue("STUDY_ID", dataType.getStudy().toString());
                job.getJobMeta().setParameterValue("TOP_NODE", topNode);

                //job.getJobMeta().setParameterValue("JAVA_HOME", "/usr/local/jdk1.6.0_31");

                job.getJobMeta().setParameterValue("TM_CZ_DB_SERVER", PreferencesHandler.getDbServer());
                job.getJobMeta().setParameterValue("TM_CZ_DB_NAME", PreferencesHandler.getDbName());
                job.getJobMeta().setParameterValue("TM_CZ_DB_PORT", PreferencesHandler.getDbPort());
                job.getJobMeta().setParameterValue("TM_CZ_DB_USER", PreferencesHandler.getTm_czUser());
                job.getJobMeta().setParameterValue("TM_CZ_DB_PWD", PreferencesHandler.getTm_czPwd());
                job.getJobMeta().setParameterValue("TM_LZ_DB_SERVER", PreferencesHandler.getDbServer());
                job.getJobMeta().setParameterValue("TM_LZ_DB_NAME", PreferencesHandler.getDbName());
                job.getJobMeta().setParameterValue("TM_LZ_DB_PORT", PreferencesHandler.getDbPort());
                job.getJobMeta().setParameterValue("TM_LZ_DB_USER", PreferencesHandler.getTm_lzUser());
                job.getJobMeta().setParameterValue("TM_LZ_DB_PWD", PreferencesHandler.getTm_lzPwd());

                job.start();
                job.waitUntilFinished();
                @SuppressWarnings("unused")
                Result result = job.getResult();
                loadDataUI.displayMessage("Loading process is over.\n Please check monitoring step.");

                Log4jBufferAppender appender = CentralLogStore.getAppender();
                String logText = appender.getBuffer(job.getLogChannelId(), false).toString();

                Pattern pattern = Pattern.compile(".*Finished job entry \\[run i2b2_process_mrna_data\\].*",
                        Pattern.DOTALL);
                Matcher matcher = pattern.matcher(logText);
                if (matcher.matches()) {
                    String connectionString = "jdbc:oracle:thin:@" + PreferencesHandler.getDbServer() + ":"
                            + PreferencesHandler.getDbPort() + ":" + PreferencesHandler.getDbName();
                    Connection con = DriverManager.getConnection(connectionString,
                            PreferencesHandler.getTm_czUser(), PreferencesHandler.getTm_czPwd());
                    Statement stmt = con.createStatement();

                    //remove rows for this study before adding new ones
                    ResultSet rs = stmt.executeQuery(
                            "select max(JOB_ID) from CZ_JOB_AUDIT where STEP_DESC='Starting i2b2_process_mrna_data'");
                    int jobId;
                    if (rs.next()) {
                        jobId = rs.getInt("max(JOB_ID)");
                    } else {
                        con.close();
                        loadDataUI.setIsLoading(false);
                        return;
                    }

                    logText += "\nOracle job id:\n" + String.valueOf(jobId);
                    con.close();
                }

                writeLog(logText);
                CentralLogStore.discardLines(job.getLogChannelId(), false);
            } catch (Exception e1) {
                //this.write(e1.getMessage());
                loadDataUI.displayMessage("Error: " + e1.getLocalizedMessage());
                loadDataUI.setIsLoading(false);
                e1.printStackTrace();
            }
            loadDataUI.setIsLoading(false);
        }
    }.start();
    this.loadDataUI.waitForThread();
    WorkPart.updateSteps();
    WorkPart.updateFiles();
}

From source file:gdsc.smlm.ij.plugins.PeakFit.java

public int setup(String arg, ImagePlus imp) {
    plugin_flags = FLAGS;//from  w  w w .j  a  va2 s  . c  o  m
    extraOptions = Utils.isExtraOptions();

    maximaIdentification = (arg != null && arg.contains("spot"));
    fitMaxima = (arg != null && arg.contains("maxima"));
    simpleFit = (arg != null && arg.contains("simple"));
    boolean runSeries = (arg != null && arg.contains("series"));

    ImageSource imageSource = null;
    if (fitMaxima) {
        imp = null;
        // The maxima will have been identified already. 
        // The image source will be found from the peak results.
        if (!showMaximaDialog())
            return DONE;

        MemoryPeakResults results = ResultsManager.loadInputResults(inputOption, false);
        if (results == null || results.size() == 0) {
            IJ.error(TITLE, "No results could be loaded");
            return DONE;
        }

        imageSource = results.getSource();
        plugin_flags |= NO_IMAGE_REQUIRED;
    } else if (runSeries) {
        imp = null;
        // Select input folder
        String inputDirectory;
        inputDirectory = IJ.getDirectory("Select image series ...");
        //inputDirectory = getInputDirectory("Select image series ...");
        if (inputDirectory == null)
            return DONE;

        // Load input series ...
        SeriesOpener series = new SeriesOpener(inputDirectory, true);
        if (series.getNumberOfImages() == 0) {
            IJ.error(TITLE, "No images in the selected directory:\n" + inputDirectory);
            return DONE;
        }

        imageSource = new SeriesImageSource(getName(series.getImageList()), series);
        ((SeriesImageSource) imageSource).setLogProgress(true);
        plugin_flags |= NO_IMAGE_REQUIRED;
    } else {
        if (imp == null) {
            IJ.noImage();
            return DONE;
        }

        // Check it is not a previous result
        if (imp.getTitle().endsWith(IJImagePeakResults.IMAGE_SUFFIX)) {
            IJImageSource tmpImageSource = null;

            // Check the image to see if it has an image source XML structure in the info property
            Object o = imp.getProperty("Info");
            Pattern pattern = Pattern.compile("Source: (<.*IJImageSource>.*<.*IJImageSource>)", Pattern.DOTALL);
            Matcher match = pattern.matcher((o == null) ? "" : o.toString());
            if (match.find()) {
                ImageSource source = ImageSource.fromXML(match.group(1));
                if (source instanceof IJImageSource) {
                    tmpImageSource = (IJImageSource) source;
                    if (!tmpImageSource.open()) {
                        tmpImageSource = null;
                    } else {
                        imp = WindowManager.getImage(tmpImageSource.getName());
                    }
                }
            }

            if (tmpImageSource == null) {
                // Look for a parent using the title
                String parentTitle = imp.getTitle().substring(0,
                        imp.getTitle().length() - IJImagePeakResults.IMAGE_SUFFIX.length() - 1);
                ImagePlus parentImp = WindowManager.getImage(parentTitle);
                if (parentImp != null) {
                    tmpImageSource = new IJImageSource(parentImp);
                    imp = parentImp;
                }
            }
            String message = "The selected image may be a previous fit result";
            if (tmpImageSource != null)
                message += " of: \n \n" + tmpImageSource.getName() + " \n \nFit the parent?";
            else
                message += " \n \nDo you want to continue?";

            YesNoCancelDialog d = new YesNoCancelDialog(null, TITLE, message);
            if (tmpImageSource == null) {
                if (!d.yesPressed())
                    return DONE;
            } else {
                if (d.yesPressed())
                    imageSource = tmpImageSource;
                if (d.cancelPressed())
                    return DONE;
            }
        }

        if (imageSource == null)
            imageSource = new IJImageSource(imp);
    }

    time = -1;

    if (!initialiseImage(imageSource, getBounds(imp), false)) {
        IJ.error(TITLE, "Failed to initialise the source image: " + imageSource.getName());
        return DONE;
    }

    int flags = showDialog(imp);
    if ((flags & DONE) == 0) {
        // Repeat so that we pass in the selected option for ignoring the bounds.
        // This should not be necessary since it is set within the readDialog method.
        //if (ignoreBoundsForNoise)
        //   initialiseImage(imageSource, bounds, ignoreBoundsForNoise);
        initialiseFitting();
    }
    return flags;
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.css.FerramentaCSSPanel.java

/**
 * Retorna o caminho do CSS/*from  www  . ja  v  a  2 s .  c o  m*/
 * 
 * @param codHtml
 * @return String com o path ou null
 */
private String getCssUrl(String codHtml) {
    Pattern pat = Pattern.compile("<link\\s.*?>", Pattern.DOTALL);
    Matcher mat = pat.matcher(codHtml);
    RegrasHardCodedEmag regra = new RegrasHardCodedEmag();
    while (mat.find()) {
        String tag = mat.group();
        String tipo = regra.getAtributo(tag, "type");
        String href = regra.getAtributo(tag, "href");
        if (tipo.equals("text/css") || href.toLowerCase().endsWith(".css")) {
            return href;
        }
    }
    return null;
}

From source file:org.apache.nifi.processors.standard.EvaluateRegularExpression.java

int getCompileFlags(ProcessContext context) {
    int flags = (context.getProperty(UNIX_LINES).asBoolean() ? Pattern.UNIX_LINES : 0)
            | (context.getProperty(CASE_INSENSITIVE).asBoolean() ? Pattern.CASE_INSENSITIVE : 0)
            | (context.getProperty(COMMENTS).asBoolean() ? Pattern.COMMENTS : 0)
            | (context.getProperty(MULTILINE).asBoolean() ? Pattern.MULTILINE : 0)
            | (context.getProperty(LITERAL).asBoolean() ? Pattern.LITERAL : 0)
            | (context.getProperty(DOTALL).asBoolean() ? Pattern.DOTALL : 0)
            | (context.getProperty(UNICODE_CASE).asBoolean() ? Pattern.UNICODE_CASE : 0)
            | (context.getProperty(CANON_EQ).asBoolean() ? Pattern.CANON_EQ : 0)
            | (context.getProperty(UNICODE_CHARACTER_CLASS).asBoolean() ? Pattern.UNICODE_CHARACTER_CLASS : 0);
    return flags;
}

From source file:org.eclipse.mylyn.internal.web.tasks.WebRepositoryConnector.java

public static IStatus performQuery(String resource, String regexp, String taskPrefix, IProgressMonitor monitor,
        TaskDataCollector resultCollector, TaskRepository repository) {
    NamedPattern p = new NamedPattern(regexp, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL
            | Pattern.UNICODE_CASE | Pattern.CANON_EQ);

    Matcher matcher = p.matcher(resource);

    if (!matcher.find()) {
        return Status.OK_STATUS;
    } else {/*w  ww  .  j  a  v  a2 s .  c o m*/
        boolean isCorrect = true;
        do {
            if (p.getGroups().isEmpty()) {
                // "classic" mode, no named patterns
                if (matcher.groupCount() < 2) {
                    isCorrect = false;
                }
                if (matcher.groupCount() >= 1) {
                    String id = matcher.group(1);
                    String description = matcher.groupCount() > 1 ? cleanup(matcher.group(2), repository)
                            : null;
                    description = unescapeHtml(description);

                    TaskData data = createTaskData(repository, id);
                    TaskMapper mapper = new TaskMapper(data, true);
                    mapper.setCreationDate(DEFAULT_DATE);
                    mapper.setTaskUrl(taskPrefix + id);
                    mapper.setSummary(description);
                    mapper.setValue(KEY_TASK_PREFIX, taskPrefix);
                    resultCollector.accept(data);
                }
            } else {
                String id = p.group("Id", matcher); //$NON-NLS-1$
                String description = p.group("Description", matcher); //$NON-NLS-1$
                if (id == null || description == null) {
                    isCorrect = false;
                }
                if (id != null) {
                    description = unescapeHtml(description);

                    String owner = unescapeHtml(cleanup(p.group("Owner", matcher), repository)); //$NON-NLS-1$
                    String type = unescapeHtml(cleanup(p.group("Type", matcher), repository)); //$NON-NLS-1$

                    TaskData data = createTaskData(repository, id);
                    TaskMapper mapper = new TaskMapper(data, true);
                    mapper.setCreationDate(DEFAULT_DATE);
                    mapper.setTaskUrl(taskPrefix + id);
                    mapper.setSummary(description);
                    mapper.setValue(KEY_TASK_PREFIX, taskPrefix);
                    mapper.setOwner(owner);
                    mapper.setTaskKind(type);

                    String status = p.group("Status", matcher); //$NON-NLS-1$
                    if (status != null) {
                        if (COMPLETED_STATUSES.contains(status.toLowerCase())) {
                            // TODO set actual completion date here
                            mapper.setCompletionDate(DEFAULT_DATE);
                        }
                    }

                    resultCollector.accept(data);
                }
            }
        } while (matcher.find() && !monitor.isCanceled());

        if (isCorrect) {
            return Status.OK_STATUS;
        } else {
            return new Status(IStatus.ERROR, TasksWebPlugin.ID_PLUGIN, IStatus.ERROR,
                    Messages.WebRepositoryConnector_Require_two_matching_groups, null);
        }
    }
}

From source file:org.kepler.kar.karxml.KarXmlGenerator.java

/**
 * Strip out the "<?xml" tag from the xml. Also removes a header DOCTYPE, if present.
 * //from   w  ww. j  av  a2s  .co m
 * @param xml
 * @return
 */
public String processXmlEntryContents(String xml) {

    xml = xml.replaceAll("<\\?xml.*?>", "");
    xml = Pattern.compile("<!DOCTYPE.*?>", Pattern.DOTALL).matcher(xml).replaceAll("");
    return xml;
}

From source file:com.parse.OfflineQueryLogic.java

/**
 * Matches $regex constraints./* w  w  w  . ja  v  a2s  . c  o m*/
 */
private static boolean matchesRegexConstraint(Object constraint, Object value, String options)
        throws ParseException {
    if (value == null || value == JSONObject.NULL) {
        return false;
    }

    if (options == null) {
        options = "";
    }

    if (!options.matches("^[imxs]*$")) {
        throw new ParseException(ParseException.INVALID_QUERY,
                String.format("Invalid regex options: %s", options));
    }

    int flags = 0;
    if (options.contains("i")) {
        flags = flags | Pattern.CASE_INSENSITIVE;
    }
    if (options.contains("m")) {
        flags = flags | Pattern.MULTILINE;
    }
    if (options.contains("x")) {
        flags = flags | Pattern.COMMENTS;
    }
    if (options.contains("s")) {
        flags = flags | Pattern.DOTALL;
    }

    String regex = (String) constraint;
    Pattern pattern = Pattern.compile(regex, flags);
    Matcher matcher = pattern.matcher((String) value);
    return matcher.find();
}