Java正则表达式用于已完成的匹配大小写

时间:2018-06-13 03:49:01

标签: java regex

我一直在努力为语法{//<some string>/<some String>}

找到带有Java正则表达式的匹配字符串

我的正则表达式应该返回这些匹配的情况:{// data / process_id}

下面是我想要找到匹配语法的字符串:

@process_id={//data/process_id}#@history_id={//data/history_id}#@Pdataxml={//data/dataxml}#@Prules =_UNESCAPEXMLVALUE({//data/rules})#@submitted_by={//data/submitted_by}#@table_definition={//data/table_definition}

我尝试使用以下regx模式,但它不起作用: [a-zA-Z_/\\[\\]\\(\\)0-9|]+

有人可以帮我解决这个问题吗?

2 个答案:

答案 0 :(得分:0)

使用匹配器尝试此正则表达式:

<?php

function itilizedWords( $subjects, $arrayToSearch ){

    foreach( $arrayToSearch as $chars )
    {
        $regex = '|(?!<i>)(' . $chars . ')(?!</i>)|';

        if( preg_match( $regex, $subjects, $matches) )
            $subjects = preg_replace( $regex, '<i>' . $matches[0] . '</i>', $subjects );
    }

    return $subjects;
}

$arrayToSearch = [
    "Prima facie", "De facto", "Vis-à-vis", "De future",
    "De future", "De integro", "De integro", "De jure", "Inter alia", "De novo", 
    "Viz", "De minimis", "Res gestae","De minimis non curat lex", 
    "Res Gestae Divi Augusti", "et seq.","et seq.", "Ex facie ", "A priori ", 
    "A priori", "A posteriori","Ex gratia", "A quo ", "Ex officio", "Ab extra", 
    "Ab extra", "Ab initio","Ex post facto", "Absque hoc", "Factum", 
    "Actori incumbit probation", "Habeas corpus", "Actus reus",  "Functus officio", 
    "Ad coelom ", "Ad coelom ", "Ad colligenda bona", "Idem ", "Ad hoc", "In absentia", 
    "Ad hominem", "In curia", "Ad idem", "In extenso", "Ad infinitum", "In futuro", 
    "Ad litem", "In haec verba", "Ad quod damnum", "In limine","Ad valorem",
    "Pari material", "Adjournment sine die", "Adjournment sine die","Amicus curiae", 
    "Amicus curiae", "Animus nocendi", "Inter se", "Animus revertendi","Intra vires", 
    "Arguendo", "Arguendo", "Audi alteram partem", "Ipso facto", "Bona fide",
    "Jus cogens", "Mala fide", "Locus standi", "Certiorari", "Mandamus",
    "Contra proferentem","Contra proferentem","Coram non judice","Modus operandi",
    "Cuius est solum eius est usque ad coelum et ad inferos","Nemo judex in sua causa",
    "Status quo ante","Nisi","Stare decisis","Non est factum","Per se ","Per se ",
    "Res gestae ","Uberrima fides","Vice versa","Mutatis Mutandis","Wednesbury"
];

$subjects ="This is the Prima facie tried to do this it's been ....Prima facie <p><i>Prima facie</i></P> Prima facie  <p>Status quo ante  Uberrima fides</P> <i>Uberrima fides</i> <p>Mutatis Mutandis Wednesbury</p> <p><i>In futuro</i></p>";

echo htmlentities( itilizedWords( $subjects, $arrayToSearch ) );

零件在第1组和第2组中捕获。

像这样:

ReplaySubject

要抓住从ReplaySubject得到的全部内容,请使用此正则表达式:

next()

答案 1 :(得分:0)

您可以使用以下正则表达式:

/opt/apps/conf/database.properties

Demo on regex101

<强>码

development.jndi=java:comp/env/jdbc/acme

<强>输出:

public static void main(String[] clargs) {
    before("/*", (req, res) -> {
       Base.open(); //will pickup 'development' connection from property file 
    });
    after("/*", (req, res) -> {
        Base.close(); // really connection goes back to pool
    });
    get("/exit", (req, res) -> {
        System.exit(0);
        return "Application shutdown";
    });
}