Reputation: 5199
I am looking for a regular expression for a contains type search on a set string. The values in my database are....
Price Override Report
Shorts And Overs Report
Import Status
In my application my user can pass in "REP", "REPORT" or "REPORTS" which I create a regular expression from and all of those should match the first two rows. I think the rule should be that at least three characters in the regular expression string are contained in the database row however the three values can be in any part of the string.
I've given it a crack but finidng it a bit tough. So far I have...
REP{0,1}ORTS{0,1}
but I don't think that is right.
Aprreciate your help
Upvotes: 2
Views: 929
Reputation: 67968
^.*?(?:\bREP\b|\bREPORTS?\b).*$
Try this to match all line containing REP
, REPORT
or REPORTS
.See demo.
https://regex101.com/r/rU8yP6/5
Upvotes: 2
Reputation: 20486
This expression: REP(?:ORTS?)?
Will match:
Explanation:
REP (?# match REP literally)
(?: (?# start non-capturing group)
ORT (?# match ORT literally)
S? (?# optionally match S literally)
)? (?# close optional non-capturing group)
Upvotes: 4