Java Code Examples for org.elasticsearch.common.regex.Regex

The following examples show how to use org.elasticsearch.common.regex.Regex. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Elasticsearch   Source File: MultiMatchQueryParser.java    License: Apache License 2.0 6 votes vote down vote up
private void extractFieldAndBoost(QueryParseContext parseContext, XContentParser parser, Map<String, Float> fieldNameWithBoosts) throws IOException {
    String fField = null;
    Float fBoost = null;
    char[] fieldText = parser.textCharacters();
    int end = parser.textOffset() + parser.textLength();
    for (int i = parser.textOffset(); i < end; i++) {
        if (fieldText[i] == '^') {
            int relativeLocation = i - parser.textOffset();
            fField = new String(fieldText, parser.textOffset(), relativeLocation);
            fBoost = Float.parseFloat(new String(fieldText, i + 1, parser.textLength() - relativeLocation - 1));
            break;
        }
    }
    if (fField == null) {
        fField = parser.text();
    }

    if (Regex.isSimpleMatchPattern(fField)) {
        for (String field : parseContext.mapperService().simpleMatchToIndexNames(fField)) {
            fieldNameWithBoosts.put(field, fBoost);
        }
    } else {
        fieldNameWithBoosts.put(fField, fBoost);
    }
}
 
Example 2
Source Project: Elasticsearch   Source File: PatternAnalyzerProvider.java    License: Apache License 2.0 6 votes vote down vote up
@Inject
public PatternAnalyzerProvider(Index index, IndexSettingsService indexSettingsService, Environment env, @Assisted String name, @Assisted Settings settings) {
    super(index, indexSettingsService.getSettings(), name, settings);

    Version esVersion = Version.indexCreated(indexSettingsService.getSettings());
    final CharArraySet defaultStopwords;
    if (esVersion.onOrAfter(Version.V_1_0_0_RC1)) {
        defaultStopwords = CharArraySet.EMPTY_SET;
    } else {
        defaultStopwords = StopAnalyzer.ENGLISH_STOP_WORDS_SET;
    }
    boolean lowercase = settings.getAsBoolean("lowercase", true);
    CharArraySet stopWords = Analysis.parseStopWords(env, settings, defaultStopwords);

    String sPattern = settings.get("pattern", "\\W+" /*PatternAnalyzer.NON_WORD_PATTERN*/);
    if (sPattern == null) {
        throw new IllegalArgumentException("Analyzer [" + name + "] of type pattern must have a `pattern` set");
    }
    Pattern pattern = Regex.compile(sPattern, settings.get("flags"));

    analyzer = new PatternAnalyzer(pattern, lowercase, stopWords);
}
 
Example 3
Source Project: Elasticsearch   Source File: IndexNameExpressionResolver.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Identifies whether the first argument (an array containing index names) is a pattern that matches all indices
 *
 * @param indicesOrAliases the array containing index names
 * @param concreteIndices  array containing the concrete indices that the first argument refers to
 * @return true if the first argument is a pattern that maps to all available indices, false otherwise
 */
boolean isPatternMatchingAllIndices(MetaData metaData, String[] indicesOrAliases, String[] concreteIndices) {
    // if we end up matching on all indices, check, if its a wildcard parameter, or a "-something" structure
    if (concreteIndices.length == metaData.concreteAllIndices().length && indicesOrAliases.length > 0) {

        //we might have something like /-test1,+test1 that would identify all indices
        //or something like /-test1 with test1 index missing and IndicesOptions.lenient()
        if (indicesOrAliases[0].charAt(0) == '-') {
            return true;
        }

        //otherwise we check if there's any simple regex
        for (String indexOrAlias : indicesOrAliases) {
            if (Regex.isSimpleMatchPattern(indexOrAlias)) {
                return true;
            }
        }
    }
    return false;
}
 
Example 4
Source Project: Elasticsearch   Source File: SettingsFilter.java    License: Apache License 2.0 6 votes vote down vote up
public static Settings filterSettings(String patterns, Settings settings) {
    String[] patternArray = Strings.delimitedListToStringArray(patterns, ",");
    Settings.Builder builder = Settings.settingsBuilder().put(settings);
    List<String> simpleMatchPatternList = new ArrayList<>();
    for (String pattern : patternArray) {
        if (Regex.isSimpleMatchPattern(pattern)) {
            simpleMatchPatternList.add(pattern);
        } else {
            builder.remove(pattern);
        }
    }
    if (!simpleMatchPatternList.isEmpty()) {
        String[] simpleMatchPatterns = simpleMatchPatternList.toArray(new String[simpleMatchPatternList.size()]);
        Iterator<Entry<String, String>> iterator = builder.internalMap().entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<String, String> current = iterator.next();
            if (Regex.simpleMatch(simpleMatchPatterns, current.getKey())) {
                iterator.remove();
            }
        }
    }
    return builder.build();
}
 
Example 5
@Override
protected void masterOperation(GetIndexTemplatesRequest request, ClusterState state, ActionListener<GetIndexTemplatesResponse> listener) {
    List<IndexTemplateMetaData> results;

    // If we did not ask for a specific name, then we return all templates
    if (request.names().length == 0) {
        results = Arrays.asList(state.metaData().templates().values().toArray(IndexTemplateMetaData.class));
    } else {
        results = new ArrayList<>();
    }

    for (String name : request.names()) {
        if (Regex.isSimpleMatchPattern(name)) {
            for (ObjectObjectCursor<String, IndexTemplateMetaData> entry : state.metaData().templates()) {
                if (Regex.simpleMatch(name, entry.key)) {
                    results.add(entry.value);
                }
            }
        } else if (state.metaData().templates().containsKey(name)) {
            results.add(state.metaData().templates().get(name));
        }
    }

    listener.onResponse(new GetIndexTemplatesResponse(results));
}
 
Example 6
Source Project: Elasticsearch   Source File: BaseTasksRequest.java    License: Apache License 2.0 6 votes vote down vote up
public boolean match(Task task) {
    if (getActions() != null && getActions().length > 0 && Regex.simpleMatch(getActions(), task.getAction()) == false) {
        return false;
    }
    if (getTaskId().isSet()) {
        if(getTaskId().getId() != task.getId()) {
            return false;
        }
    }
    if (parentTaskId.isSet()) {
        if (parentTaskId.equals(task.getParentTaskId()) == false) {
            return false;
        }
    }
    return true;
}
 
Example 7
@SuppressWarnings("unchecked")
private List<String> getGeoShapeFieldsFromDoc(IngestDocument ingestDocument) {
    List<String> fields = new ArrayList<>();

    Map<String, Object> baseMap;
    if (path != null) {
        baseMap = ingestDocument.getFieldValue(this.path, Map.class);
    } else {
        baseMap = ingestDocument.getSourceAndMetadata();
    }

    for (String fieldName : baseMap.keySet()) {
        if (Regex.simpleMatch(field, fieldName)) {
            if (path != null) {
                fieldName = path + "." + fieldName;
            }
            fields.add(fieldName);
        }
    }

    return fields;
}
 
Example 8
Source Project: crate   Source File: IndexNameExpressionResolver.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Identifies whether the first argument (an array containing index names) is a pattern that matches all indices
 *
 * @param indicesOrAliases the array containing index names
 * @param concreteIndices  array containing the concrete indices that the first argument refers to
 * @return true if the first argument is a pattern that maps to all available indices, false otherwise
 */
boolean isPatternMatchingAllIndices(MetaData metaData, String[] indicesOrAliases, String[] concreteIndices) {
    // if we end up matching on all indices, check, if its a wildcard parameter, or a "-something" structure
    if (concreteIndices.length == metaData.getConcreteAllIndices().length && indicesOrAliases.length > 0) {

        //we might have something like /-test1,+test1 that would identify all indices
        //or something like /-test1 with test1 index missing and IndicesOptions.lenient()
        if (indicesOrAliases[0].charAt(0) == '-') {
            return true;
        }

        //otherwise we check if there's any simple regex
        for (String indexOrAlias : indicesOrAliases) {
            if (Regex.isSimpleMatchPattern(indexOrAlias)) {
                return true;
            }
        }
    }
    return false;
}
 
Example 9
Source Project: crate   Source File: IndexNameExpressionResolver.java    License: Apache License 2.0 6 votes vote down vote up
public static Map<String, AliasOrIndex> matches(Context context, MetaData metaData, String expression) {
    if (Regex.isMatchAllPattern(expression)) {
        // Can only happen if the expressions was initially: '-*'
        if (context.getOptions().ignoreAliases()) {
            return metaData.getAliasAndIndexLookup().entrySet().stream()
                    .filter(e -> e.getValue().isAlias() == false)
                    .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
        } else {
            return metaData.getAliasAndIndexLookup();
        }
    } else if (expression.indexOf("*") == expression.length() - 1) {
        return suffixWildcard(context, metaData, expression);
    } else {
        return otherWildcard(context, metaData, expression);
    }
}
 
Example 10
Source Project: crate   Source File: TransportCreatePartitionsAction.java    License: Apache License 2.0 6 votes vote down vote up
private List<IndexTemplateMetaData> findTemplates(CreatePartitionsRequest request, ClusterState state) {
    List<IndexTemplateMetaData> templates = new ArrayList<>();
    String firstIndex = request.indices().iterator().next();


    // note: only use the first index name to see if template matches.
    // this means
    for (ObjectCursor<IndexTemplateMetaData> cursor : state.metaData().templates().values()) {
        IndexTemplateMetaData template = cursor.value;
        for (String pattern : template.getPatterns()) {
            if (Regex.simpleMatch(pattern, firstIndex)) {
                templates.add(template);
                break;
            }
        }
    }
    CollectionUtil.timSort(templates, (o1, o2) -> o2.order() - o1.order());
    return templates;
}
 
Example 11
Source Project: crate   Source File: TransportGetIndexTemplatesAction.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void masterOperation(GetIndexTemplatesRequest request, ClusterState state, ActionListener<GetIndexTemplatesResponse> listener) {
    List<IndexTemplateMetaData> results;

    // If we did not ask for a specific name, then we return all templates
    if (request.names().length == 0) {
        results = Arrays.asList(state.metaData().templates().values().toArray(IndexTemplateMetaData.class));
    } else {
        results = new ArrayList<>();
    }

    for (String name : request.names()) {
        if (Regex.isSimpleMatchPattern(name)) {
            for (ObjectObjectCursor<String, IndexTemplateMetaData> entry : state.metaData().templates()) {
                if (Regex.simpleMatch(name, entry.key)) {
                    results.add(entry.value);
                }
            }
        } else if (state.metaData().templates().containsKey(name)) {
            results.add(state.metaData().templates().get(name));
        }
    }

    listener.onResponse(new GetIndexTemplatesResponse(results));
}
 
Example 12
Source Project: crate   Source File: ESIntegTestCase.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Asserts that all shards are allocated on nodes matching the given node pattern.
 */
public Set<String> assertAllShardsOnNodes(String index, String... pattern) {
    Set<String> nodes = new HashSet<>();
    ClusterState clusterState = client().admin().cluster().prepareState().execute().actionGet().getState();
    for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) {
        for (IndexShardRoutingTable indexShardRoutingTable : indexRoutingTable) {
            for (ShardRouting shardRouting : indexShardRoutingTable) {
                if (shardRouting.currentNodeId() != null && index.equals(shardRouting.getIndexName())) {
                    String name = clusterState.nodes().get(shardRouting.currentNodeId()).getName();
                    nodes.add(name);
                    assertThat("Allocated on new node: " + name, Regex.simpleMatch(pattern, name), is(true));
                }
            }
        }
    }
    return nodes;
}
 
Example 13
Source Project: Elasticsearch   Source File: DefaultIndexTemplateFilter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean apply(CreateIndexClusterStateUpdateRequest request, IndexTemplateMetaData template) {
    long tenantId = TenantProperty.ROOT_TENANT_ID;
    LoginUserContext userInfo = (LoginUserContext)request.originalMessage().getHeader(LoginUserContext.USER_INFO_KEY);
    if (userInfo != null) {
        tenantId = userInfo.tenantId();
    }
    if (tenantId != template.templateOwnerTenantId()) {
        return false;
    }
    return Regex.simpleMatch(template.template(), request.index());
}
 
Example 14
Source Project: Elasticsearch   Source File: IndicesQueryParser.java    License: Apache License 2.0 5 votes vote down vote up
protected boolean matchesIndices(String currentIndex, String... indices) {
    final String[] concreteIndices = indexNameExpressionResolver.concreteIndices(clusterService.state(), IndicesOptions.lenientExpandOpen(), indices);
    for (String index : concreteIndices) {
        if (Regex.simpleMatch(index, currentIndex)) {
            return true;
        }
    }
    return false;
}
 
Example 15
Source Project: Elasticsearch   Source File: ShardFieldData.java    License: Apache License 2.0 5 votes vote down vote up
public FieldDataStats stats(String... fields) {
    ObjectLongHashMap<String> fieldTotals = null;
    if (fields != null && fields.length > 0) {
        fieldTotals = new ObjectLongHashMap<>();
        for (Map.Entry<String, CounterMetric> entry : perFieldTotals.entrySet()) {
            if (Regex.simpleMatch(fields, entry.getKey())) {
                fieldTotals.put(entry.getKey(), entry.getValue().count());
            }
        }
    }
    return new FieldDataStats(totalMetric.count(), evictionsMetric.count(), fieldTotals);
}
 
Example 16
Source Project: Elasticsearch   Source File: PatternTokenizerFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Inject
public PatternTokenizerFactory(Index index, IndexSettingsService indexSettingsService, @Assisted String name, @Assisted Settings settings) {
    super(index, indexSettingsService.getSettings(), name, settings);

    String sPattern = settings.get("pattern", "\\W+" /*PatternAnalyzer.NON_WORD_PATTERN*/);
    if (sPattern == null) {
        throw new IllegalArgumentException("pattern is missing for [" + name + "] tokenizer of type 'pattern'");
    }

    this.pattern = Regex.compile(sPattern, settings.get("flags"));
    this.group = settings.getAsInt("group", -1);
}
 
Example 17
@Inject
public PatternReplaceTokenFilterFactory(Index index, IndexSettingsService indexSettingsService, @Assisted String name, @Assisted Settings settings) {
    super(index, indexSettingsService.getSettings(), name, settings);

    String sPattern = settings.get("pattern", null);
    if (sPattern == null) {
        throw new IllegalArgumentException("pattern is missing for [" + name + "] token filter of type 'pattern_replace'");
    }
    this.pattern = Regex.compile(sPattern, settings.get("flags"));
    this.replacement = settings.get("replacement", "");
    this.all = settings.getAsBoolean("all", true);
}
 
Example 18
Source Project: Elasticsearch   Source File: DocumentFieldMappers.java    License: Apache License 2.0 5 votes vote down vote up
public Collection<String> simpleMatchToFullName(String pattern) {
    Set<String> fields = Sets.newHashSet();
    for (FieldMapper fieldMapper : this) {
        if (Regex.simpleMatch(pattern, fieldMapper.fieldType().names().fullName())) {
            fields.add(fieldMapper.fieldType().names().fullName());
        } else if (Regex.simpleMatch(pattern, fieldMapper.fieldType().names().indexName())) {
            fields.add(fieldMapper.fieldType().names().fullName());
        }
    }
    return fields;
}
 
Example 19
Source Project: Elasticsearch   Source File: MapperService.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns all the fields that match the given pattern. If the pattern is prefixed with a type
 * then the fields will be returned with a type prefix.
 */
public Collection<String> simpleMatchToIndexNames(String pattern) {
    if (Regex.isSimpleMatchPattern(pattern) == false) {
        // no wildcards
        return Collections.singletonList(pattern);
    }
    return fieldTypes.simpleMatchToIndexNames(pattern);
}
 
Example 20
Source Project: Elasticsearch   Source File: FieldTypeLookup.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns a list of the index names of a simple match regex like pattern against full name and index name.
 */
public Collection<String> simpleMatchToIndexNames(String pattern) {
    Set<String> fields = Sets.newHashSet();
    for (MappedFieldType fieldType : this) {
        if (Regex.simpleMatch(pattern, fieldType.names().fullName())) {
            fields.add(fieldType.names().indexName());
        } else if (Regex.simpleMatch(pattern, fieldType.names().indexName())) {
            fields.add(fieldType.names().indexName());
        }
    }
    return fields;
}
 
Example 21
Source Project: Elasticsearch   Source File: FieldTypeLookup.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns a list of the full names of a simple match regex like pattern against full name and index name.
 */
public Collection<String> simpleMatchToFullName(String pattern) {
    Set<String> fields = Sets.newHashSet();
    for (MappedFieldType fieldType : this) {
        if (Regex.simpleMatch(pattern, fieldType.names().fullName())) {
            fields.add(fieldType.names().fullName());
        } else if (Regex.simpleMatch(pattern, fieldType.names().indexName())) {
            fields.add(fieldType.names().fullName());
        }
    }
    return fields;
}
 
Example 22
Source Project: Elasticsearch   Source File: CustomFieldsVisitor.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Status needsField(FieldInfo fieldInfo) throws IOException {
    if (super.needsField(fieldInfo) == Status.YES) {
        return Status.YES;
    }
    if (fields.contains(fieldInfo.name)) {
        return Status.YES;
    }
    for (String pattern : patterns) {
        if (Regex.simpleMatch(pattern, fieldInfo.name)) {
            return Status.YES;
        }
    }
    return Status.NO;
}
 
Example 23
Source Project: Elasticsearch   Source File: RestGetIndicesAliasesAction.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
    final String[] aliases = Strings.splitStringByCommaToArray(request.param("name"));

    ClusterStateRequest clusterStateRequest = Requests.clusterStateRequest()
            .routingTable(false)
            .nodes(false)
            .indices(indices);
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));

    client.admin().cluster().state(clusterStateRequest, new RestBuilderListener<ClusterStateResponse>(channel) {
        @Override
        public RestResponse buildResponse(ClusterStateResponse response, XContentBuilder builder) throws Exception {
            MetaData metaData = response.getState().metaData();
            builder.startObject();

            final boolean isAllAliasesRequested = isAllOrWildcard(aliases);
            for (IndexMetaData indexMetaData : metaData) {
                builder.startObject(indexMetaData.getIndex(), XContentBuilder.FieldCaseConversion.NONE);
                builder.startObject("aliases");

                for (ObjectCursor<AliasMetaData> cursor : indexMetaData.getAliases().values()) {
                    if (isAllAliasesRequested || Regex.simpleMatch(aliases, cursor.value.alias())) {
                        AliasMetaData.Builder.toXContent(cursor.value, builder, ToXContent.EMPTY_PARAMS);
                    }
                }

                builder.endObject();
                builder.endObject();
            }

            builder.endObject();
            return new BytesRestResponse(OK, builder);
        }
    });
}
 
Example 24
Source Project: Elasticsearch   Source File: RestTable.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Extracts all the required fields from the RestRequest 'h' parameter. In order to support wildcards like
 * 'bulk.*' this needs potentially parse all the configured headers and its aliases and needs to ensure
 * that everything is only added once to the returned headers, even if 'h=bulk.*.bulk.*' is specified
 * or some headers are contained twice due to matching aliases
 */
private static Set<String> expandHeadersFromRequest(Table table, RestRequest request) {
    Set<String> headers = new LinkedHashSet<>(table.getHeaders().size());

    // check headers and aliases
    for (String header : Strings.splitStringByCommaToArray(request.param("h"))) {
        if (Regex.isSimpleMatchPattern(header)) {
            for (Table.Cell tableHeaderCell : table.getHeaders()) {
                String configuredHeader = tableHeaderCell.value.toString();
                if (Regex.simpleMatch(header, configuredHeader)) {
                    headers.add(configuredHeader);
                } else if (tableHeaderCell.attr.containsKey("alias")) {
                    String[] aliases = Strings.splitStringByCommaToArray(tableHeaderCell.attr.get("alias"));
                    for (String alias : aliases) {
                        if (Regex.simpleMatch(header, alias)) {
                            headers.add(configuredHeader);
                            break;
                        }
                    }
                }
            }
        } else {
            headers.add(header);
        }
    }

    return headers;
}
 
Example 25
Source Project: Elasticsearch   Source File: TransportService.java    License: Apache License 2.0 5 votes vote down vote up
private boolean shouldTraceAction(String action) {
    if (tracerLogInclude.length > 0) {
        if (Regex.simpleMatch(tracerLogInclude, action) == false) {
            return false;
        }
    }
    if (tracelLogExclude.length > 0) {
        return !Regex.simpleMatch(tracelLogExclude, action);
    }
    return true;
}
 
Example 26
Source Project: Elasticsearch   Source File: TribeService.java    License: Apache License 2.0 5 votes vote down vote up
private void addNewIndex(ClusterState tribeState, ClusterBlocks.Builder blocks, MetaData.Builder metaData, RoutingTable.Builder routingTable, IndexMetaData tribeIndex) {
    Settings tribeSettings = Settings.builder().put(tribeIndex.getSettings()).put(TRIBE_NAME, tribeName).build();
    metaData.put(IndexMetaData.builder(tribeIndex).settings(tribeSettings));
    routingTable.add(tribeState.routingTable().index(tribeIndex.getIndex()));
    if (Regex.simpleMatch(blockIndicesMetadata, tribeIndex.getIndex())) {
        blocks.addIndexBlock(tribeIndex.getIndex(), IndexMetaData.INDEX_METADATA_BLOCK);
    }
    if (Regex.simpleMatch(blockIndicesRead, tribeIndex.getIndex())) {
        blocks.addIndexBlock(tribeIndex.getIndex(), IndexMetaData.INDEX_READ_BLOCK);
    }
    if (Regex.simpleMatch(blockIndicesWrite, tribeIndex.getIndex())) {
        blocks.addIndexBlock(tribeIndex.getIndex(), IndexMetaData.INDEX_WRITE_BLOCK);
    }
}
 
Example 27
Source Project: Elasticsearch   Source File: DynamicSettings.java    License: Apache License 2.0 5 votes vote down vote up
public boolean hasDynamicSetting(String key) {
    for (String dynamicSetting : dynamicSettings.keySet()) {
        if (Regex.simpleMatch(dynamicSetting, key)) {
            return true;
        }
    }
    return false;
}
 
Example 28
Source Project: Elasticsearch   Source File: DynamicSettings.java    License: Apache License 2.0 5 votes vote down vote up
public String validateDynamicSetting(String dynamicSetting, String value, ClusterState clusterState) {
    for (Map.Entry<String, Validator> setting : dynamicSettings.entrySet()) {
        if (Regex.simpleMatch(setting.getKey(), dynamicSetting)) {
            return setting.getValue().validate(dynamicSetting, value, clusterState);
        }
    }
    return null;
}
 
Example 29
Source Project: Elasticsearch   Source File: DiscoveryNodeFilters.java    License: Apache License 2.0 5 votes vote down vote up
private boolean matchByIP(String[] values, @Nullable String hostIp, @Nullable String publishIp) {
    for (String value : values) {
        boolean matchIp = Regex.simpleMatch(value, hostIp) || Regex.simpleMatch(value, publishIp);
        if (matchIp) {
            return matchIp;
        }
    }
    return false;
}
 
Example 30
Source Project: Elasticsearch   Source File: URIPattern.java    License: Apache License 2.0 5 votes vote down vote up
private boolean match(String pattern, String value) {
    if (value == null) {
        // If the pattern is empty or matches anything - it's a match
        if (pattern == null || Regex.isMatchAllPattern(pattern)) {
            return true;
        }
    }
    return Regex.simpleMatch(pattern, value);
}