Terminé

Write me a regular expression for regex (or grep!) that combines AND & OR operators...

I need a regular expression that will capture a combination of (a combination of?) two words in a sentence, with wildcards.

Simply put, it would capture any sentence with "launch" OR "began" AND "20*" OR "198*"

Therefore, if a sentence said: "we launched the product in 1981" it would be captured.

Same as if the words were reversed ("in 1981 we launched"). Same as if it said "began" instead of "launched."

The regex you provide should also allow me to customize it, so that it captures ONLY "launch" but also "launched" with some simple mods I can make.

Here are some sample texts. It should capture 1 and 2 but not 3.

1. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod

tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,

quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo

consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse

cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non

proident, sunt in culpa qui officia deserunt mollit anim id est laborum __2013 launched the beginning of the project__.

2. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod

tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,

quis nostrud exercitation __began in 1984__ ullamco laboris nisi ut aliquip ex ea commodo

consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse

cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non

proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

3. Ut labore et dolore magna aliqua. Ut enim ad minim veniam,

quis nostrud exercitation __beginning in 1990__ ut labore et dolore magna aliqua. Ut enim ad minim veniam, dolore magna aliqua. Ut enim ad minim veniam, dolore magna aliqua. Ut enim ad minim veniam,

==========PRO TIP=========

There seems to be a partial answer here: [login to view URL]

But I feel that it's a combination of the solutions in

^.*\b(one|two|three)\b.*$

and

^(?=.*?\bone\b)(?=.*?\btwo\b)(?=.*?\bthree\b).*$

It's certainly not

(198)|(200)(.+?)(began)|(launch)(.*)

which captures ALL occurrences of ANY of the items.

==========SECOND PRO TIP=========

I will probably be using either PowerGREP in windows or maybe just grep via command line, so the solution could be tailored to that?

This will be for finding these expressions in a folder of thousands of txt and html files and extracting them for analysis.

Compétences : Expressions régulières

en voir plus : regular expression examples, grep multiple strings, grep regex linux, linux regex, regex tester, grep regex or, grep extended regex, egrep regex, regular expression examples extract data, regular expression freelance, extract data html page regular expression, str_replace regular expression, sms message regular expression php, regular expression spaces, regular expression extract information html, stl store regular expression, mysql regular expression perl, extract table html page regular expression, regular expression data table, convert links clickable regular expression php

Concernant l'employeur :
( 2 commentaires ) New York, United States

Nº du projet : #17937649

Décerné à:

%selectedBids___i_sum_sub_4% %project_currencyDetails_sign_sub_5% USD en 1 jour
(0 Commentaires)
0.0