首页 \ 问答 \ Solr 4.x和SolrCloud(Solr 4.x and SolrCloud)

Solr 4.x和SolrCloud(Solr 4.x and SolrCloud)

我不太清楚SolrCloud是单独的包还是Solr包的一部分(在4.x中)? 我正在阅读http://wiki.apache.org/solr/SolrCloud 。 最初我认为SolrCloud是一个单独的包,但是当我通过维基页面阅读时,我得到的印象是SolrCloud是Solr包的一部分?

如果有人能澄清,那将是伟大的。


It is not very clear to me whether SolrCloud is a separate package or a part of Solr package (in 4.x)? I was reading http://wiki.apache.org/solr/SolrCloud. Initially I thought SolrCloud is a separate package but as I read thru the wiki page, I got an impression that SolrCloud is a part of the Solr package?

If someone could clarify, that will be great.


原文:https://stackoverflow.com/questions/17637077
更新时间:2023-11-06 12:11

最满意答案

不太确定你在这里尝试了什么,但是如果我要制作一个与单词列表匹配的正则表达式(或者根据具体情况可能是函数名称),我会做类似的事情。

// add/remove allowed stuff here
$allowed = array( 'nl2br', 'substr', 'addslashes' );

// make the array into a branching pattern
$allowed_pattern = implode('|', $allowed);

// the entire regexp (a little stricter than yours)    
$pattern = "/\{function=\"($allowed_pattern)\((.*?)\)\"\}/";

if( preg_match($pattern, $string, $matches) ) {
    # string DOES contain an allowed function
    # The $matches things is optional, but nice. $matches[1] will be the function name, and
    # $matches[2] will be the arguments string. Of course, you could just do a
    # preg_replace_callback() on everything instead using the same pattern...
} else {
    # No allowed functions found
}

$allowed数组使得添加/删除允许的函数名称变得更容易,并且regexp对于大括号,引号和一般语法更加严格,这可能是一个好主意。

但首先,翻转if..else分支,或使用!preg_match用于匹配字符串中的东西,而不是用于匹配那里不存在的东西。 所以你不能真正让它回归那些存在的东西

尽管如此,正如Álvaro所提到的,正则表达式可能并不是解决这个问题的最佳方式,而且无论代码的其余部分如何,将函数暴露出来都是非常危险的。 如果你只是需要匹配单词它应该工作正常,但因为它的函数调用任意参数......好吧。 我不能真的推荐它:)

编辑:第一次,我preg_quote爆字符串上使用preg_quote ,但这当然只是转义管道字符,然后模式将无法工作。 所以跳过preg_quote ,但是请确保函数名称不包含任何可能搞乱最终模式的内容(例如, 插入数组之前通过preg_quote运行每个函数名称)


Not quite sure what you're trying here, but if I were to make a regexp that matched a list of words (or function names as the case may be), I'd do somthing like

// add/remove allowed stuff here
$allowed = array( 'nl2br', 'substr', 'addslashes' );

// make the array into a branching pattern
$allowed_pattern = implode('|', $allowed);

// the entire regexp (a little stricter than yours)    
$pattern = "/\{function=\"($allowed_pattern)\((.*?)\)\"\}/";

if( preg_match($pattern, $string, $matches) ) {
    # string DOES contain an allowed function
    # The $matches things is optional, but nice. $matches[1] will be the function name, and
    # $matches[2] will be the arguments string. Of course, you could just do a
    # preg_replace_callback() on everything instead using the same pattern...
} else {
    # No allowed functions found
}

The $allowed array makes it easier to add/remove allowed function names, and the regexp is stricter about the curly brackets, quotes and general syntax, which is probably a good idea.

But first of all, flip the if..else branches, or use a !. preg_match is meant for, well, matching stuff in the string, not for matching stuff that isn't in there. So you can't really get it to return true for something that isn't there

Still, as Álvaro mentioned, regexps probably aren't the best way to go about this, and it is pretty risky to have functions exposed like that, no matter the rest of the code. If you just needed to match words it should work fine, but since it's function calls with arbitrary arguments... well. I can't really recommend it :)

Edit: First time around, I used preg_quote on the imploded string, but that of course just escapes the pipe characters, and then the pattern won't work. So skip preg_quote, but then just be sure that function names don't contain anything that might mess up the final pattern (e.g. run each function name through preg_quote before imploding the array)

相关问答

更多
  • 从我所看到的,你根本不需要preg_match 。 然而,你遇到的问题是逃避。 你有这个: "/[a-zA-Z]\\_[a-zA-Z]/" 您已经正确识别出需要转义反斜杠,但是,您错过了一个微妙的问题: PHP中的正则表达式是字符串。 这意味着您需要将其作为字符串和正则表达式进行转义。 实际上,这意味着要正确地转义反斜杠以使其与模式中的实际反斜杠字符匹配,实际上需要有四个反斜杠。 "/[a-zA-Z]\\\\_[a-zA-Z]/" 它不漂亮,但就是这样。 希望有所帮助。 You don't really ...
  • 你可以使用这个正则表达式 \w+(-\w+){3,} \w类似于[a-zA-Z0-9_] \w+匹配1到多个字符 {3,}是一个量词,它匹配前面的组3到很多次 You can use this regex \w+(-\w+){3,} \w is similar to [a-zA-Z0-9_] \w+ matches 1 to many character {3,} is a quantifier that matches preceding group 3 to many times
  • 正则表达式工作正常 。 你错过了分隔符吗? 该函数应该像这样使用: preg_match('/[0-9\.]+/', $string, $result); (顺便说一句,你不需要在字符类中转义。 [0-9.]就足够了。) The regex works fine. Are you missing the delimiters? The function should be used like this: preg_match('/[0-9\.]+/', $string, $result); (BTW, ...
  • 尝试更简单的事情: $regex = "/Disponible:\D+(\d+)/"; preg_match($regex,$string,$match); var_dump($match[1]); 正则表达的力量源于它们的灵活性。 Try something much simpler: $regex = "/Disponible:\D+(\d+)/"; preg_match($regex,$string,$match); var_dump($match[1]); The power of regexe ...
  • 尝试下面的代码: $value = '123-123-123-12345'; if(preg_match("/^[0-9]{3}\-[0-9]{3}\-[0-9]{3}\-[0-9]{5}+$/", $value)) { echo "Yeah match Elm: ".$value."
    "; } else { echo "Boo Hoo Elm: '".$value."'
    "; } (不确定\是否有用 - 但在这种情况下它们似乎不会造成任何麻烦) 我得到: Ye ...
  • 对于具体的链接 /http:\/\/[a-zA-Z]{3}\.[a-zA-Z]{2}\/[a-zA-Z]{7}\/[a-zA-Z]{6}\/\d{12}/ 在线测试 - > http://www.functions-online.com/preg_match.html 如果你想了解我做了什么(在页面底部是一个备忘单) http://regex101.com/ ps:这个模式只适用于你提供的链接,可以'保证其他人可以工作,阅读备忘单 for the concrete link /http:\/\/[a-zA- ...
  • 解决方案 我首先从字符串中删除所有特殊字符和数字,然后使用字边界匹配单词: $cleaned = preg_replace('/[^a-z ]+/i', '', 'This is dem*#o text, contains de12mo3 text, is .demo23* text'); preg_match_all('/\bdemo\b/i', $cleaned, $matches, PREG_OFFSET_CAPTURE); var_dump($matches); 会给你( Codepad De ...
  • $pattern = "%(\d+) */ *(\d+)%"; $test = array( 'half is 1/2', '13/100 is your score', 'only 23 /90 passed', 'no idea here:7/ 123', '24 / 25', '1a/2b' ); foreach($test as $t){ if(preg_match($pattern, $t, $matches)) echo ...
  • 使用preg_match_all获取所有匹配项。 preg_match只会返回第一个匹配项。 Count将返回两个因为您捕获一个组。 Use preg_match_all to get all matches. preg_match will only return the first match. Count will return two because you capture a group.
  • 不太确定你在这里尝试了什么,但是如果我要制作一个与单词列表匹配的正则表达式(或者根据具体情况可能是函数名称),我会做类似的事情。 // add/remove allowed stuff here $allowed = array( 'nl2br', 'substr', 'addslashes' ); // make the array into a branching pattern $allowed_pattern = implode('|', $allowed); // the entire reg ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)