英文:
Find text match between two start and end parameters
问题
正则表达式 (color[^$]*blue)
期望结果:
color Dolores ducimus nulla doloribus quod odit modi perspiciatis delectus earum nisi, sit ex! blue
COLOR deleniti iure ipsam beatae nostrum vel dolore dolorum id esse inventore eligendi velit ut temporibus eius in, BLUE
colorpraesentium accusamus, magnam nesciunt cumque fugiat nonblue
英文:
I would like to know if there is a more optimal or the most efficient literal to match all variants to find all the conicidences of a text, passing two params (start, end), regardless of the internal characters.
REGEX (color[^$]*blue)
Lorem ipsum dolor, sit amet consectetur adipisicing elit. color Dolores ducimus nulla doloribus quod odit modi perspiciatis delectus earum nisi, sit ex! blue Doloribus dolores provident hic consequuntur natus ipsa inventore expedita!
Fugit autem saepe fuga maiores quo optio exercitationem reiciendis COLOR deleniti iure ipsam beatae nostrum vel dolore dolorum id esse inventore eligendi velit ut temporibus eius in, BLUE corrupti laboriosam modi. Excepturi.
Iure maiores, fuga neque vitae est repellendus colorpraesentium accusamus, magnam nesciunt cumque fugiat nonblue impedit! Laborum exercitationem architecto fugiat libero eaque provident voluptatem aperiam unde nulla impedit porro, itaque nisi.
Expected result
color Dolores ducimus nulla doloribus quod odit modi perspiciatis delectus earum nisi, sit ex! blue
COLOR deleniti iure ipsam beatae nostrum vel dolore dolorum id esse inventore eligendi velit ut temporibus eius in, BLUE
colorpraesentium accusamus, magnam nesciunt cumque fugiat nonblue
答案1
得分: 1
如果您期望的结果是您想要的,这应该是您的解决方案:
https://regexr.com/4rjt3
标志 "i" 将使正则表达式不区分大小写。
请注意 - 我将 [^$]
替换为 (.*)
,以便您可以单独获取结果。
英文:
If the expected result is what you want, this is should be your solution:
https://regexr.com/4rjt3
The flag "i", will make the regex not case sensitive.
Please notice - I replaced [^$]
with (.*)
so you will get the results separately.
答案2
得分: 1
这匹配了从"color"到"blue"之间的所有内容(包括它们),没有"color"或"blue"之间的内容:
(?i)color(?:(?!color|blue).)*blue
英文:
This matches all between color and blue (included) with no color or blue in between:
(?i)color(?:(?!color|blue).)*blue
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论