正则表达式字符串捕获JavaScript(regex string capturing javascript)
我是javascript的正则表达式的新手。 我有一个类似下面的字符串:
“ 和这里的东西(这里的东西和 (这里的东西,这里有什么东西)别的东西或其他东西)asdf( 或 asdfas) 和这里的东西或其他什么东西(这里还有别的东西或别的东西)”
从上面的字符串,我试图根据以下规则捕获文本组:
- 捕获以
"and"
或"or"
开头并以"or"
或"and"
结尾的行- 捕获的行可以有许多括号。
- 如果运算符
"or"
或"and"
在括号中,则忽略它们从上面的字符串,我期待如下所示的结果组
- 和这里的东西(这里的东西和 (这里的东西和这里的东西)别的东西或其他东西)asdf( 或 asdfas)
- 还有什么在这里
- 或者这里的东西(这里的其他东西和其他东西或其他东西)
我尝试了许多正则表达式,并且接近我想要的正则表达式是:
(and|or)\s.((?!(and|or)).)*
我也可以使用非正则表达式解决方案。
I am new to regex in javascript. I have a string something like below:
"and something here ( something else here and (something here and something here) something else or something else) asdf (or asdfas) and something here or something here ( something else here and something else or something else)"
From the above string, I am trying to capture group of text based on the following rules:
- Capture a line which starts with
"and"
or"or"
and ends with"or"
or"and"
- A captured line can have many parenthesis.
- If the operators
"or"
or"and"
are in parenthesis, then ignore themFrom the above string, I am expecting group of result as shown below
- and something here ( something else here and (something here and something here) something else or something else) asdf (or asdfas)
- and something here
- or something here ( something else here and something else or something else)
I have tried many regexes and the one which is close to what I want is:
(and|or)\s.((?!(and|or)).)*
I am ok with a non-regex solution too.
原文:
最满意答案
You Need to create three product category to separate all these product. You need to do ..... 1. Go to Products -> Categories. Then you need to add three categories like Men Women and Brand. 2. After that, When you add product or edit your product, you just need to check the category of the product.
相关问答
更多-
MySQL SELECT女性不是男性(MySQL SELECT women not men)[2023-10-29]
好吧,如果你实际存储的单词“男人”或“女性”,你的数据库设置不正确 您应该使用链接表让我们说categories将产品链接到类别。 然后你可以这样做: SELECT * FROM products p JOIN categoriesToProducts ctp ON ctp.productId = p.productId JOIN categories c ON c.categoryId = ctp.categoryId WHERE c.categoryName = "Men"; Well if you ... -
通过使用panda或scikit学习python库,并使用python语言,您可以组合特征变量。 By using panda or scikit learning python libraries, and by using python language, you can combine feature variables.
-
像这样的东西: 数据准备 df <- read.table(text = "state capital_name lat long women_earnings men_earning Alabama Montgomery 32.36154 -86.27912 621 832 ...
-
更新:我之前的回答使用$.grep ,但更好的选择是filter : $(".row").hide().filter(function() { return $(this).find(".category span").text().indexOf(searchTerm) >= 0; }).show(); jsFiddle的工作示例。 细节: 这将选择所有行,隐藏它们并返回相同的数组 $(".row").hide() ...然后将传递给filter (将按某种条件过滤它)。 $(".row"). ...
-
查看主题的catalog.xml文件。 你应该找到这样的东西,如果这是相同的后端产品,则应使用一个sku来跟踪它。 也就是说,我知道您可能会有一些相互矛盾的要求。 在没有完全破坏系统后端的情况下,我能想到的唯一方法就是为“前端sku”创建一个字段,用于在每个商店的基础上向客户显示。 您需要使用每个商店的sku替换前端中的引用,并且仍然会在后端看到真正的sku。 If this is the same backend product, one sku should be used to track it. That said, I understand that you ...您无法在单个调用中获取产品和变体,您需要进行其他调用以获取变体。 you can't fetch product and variants in single call you need to make other calls to get variants.
CSS:下拉男人的全宽(CSS: Full width of drop down men)[2022-12-19]
您可以使用display:flex来实现此目的。 检查下面的解决方案,这是小提琴 .nav, .nav a, .nav ul, .nav li, .nav div, .nav form, .nav input { margin: 0; padding: 0; border: none; outline: none; } .nav a { text-decoration: none; } .nav li { list-style: none; ...您需要创建三个产品类别来分隔所有这些产品。 你需要做..... 1.转到产品 - >类别。 然后你需要添加三个类别,如男性女性和品牌。 2.之后,当您添加产品或编辑产品时,您只需要检查产品的类别。 You Need to create three product category to separate all these product. You need to do ..... 1. Go to Products -> Categories. Then you need to add three cat ...这不是Magento Community Edition(或Enterprise)中的“开箱即用”功能,因此您需要编写一些代码才能使其正常工作。 一般而言,您需要: 向产品添加(隐藏?)属性以存储产品“所有者”的用户ID。 编写catalog_product_save_before的事件观察器,将当前用户的User Id字段分配给新的产品所有者属性。 重写_prepareCollection或_addColumnFilterToCollection方法,将product_owner属性添加到集合中,并将其过 ...相关文章
更多- 在javascript中正则表达式拆分字符串
- javascript正则表达式怎么多行匹配
- Java正则表达式
- JAVA 正则表达式教程(超详细)一
- 揭开正则表达式的神秘面纱
- javascript 问题
- 关于正则表达式的问题 大家一起来解释下
- 关于正则表达式空格的问题.
- 快速了解正则表达式
- Java String类
最新问答
更多- 您如何使用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)