Reputation: 3
I need to combine these 2 regexes
^.*(Completed: BALI - Job).*$
and \b(BALI_)(INVOICES|CORRESPONDENCE|LATE_SCANNINGS)\b
into one so that it should match "Completed: BALI - Job"
as a mandatory and "BALI_INVOICES or BALI_CORRESPONDENCE or BALI_LATE_SCANNINGS"
as alternatives
Upvotes: 0
Views: 140
Reputation: 2362
As the second part is optional, a ?
is appended.
^.*(Completed: BALI - Job).*(\b(BALI_)(INVOICES|CORRESPONDENCE|LATE_SCANNINGS)\b)?
Upvotes: 1
Reputation: 4494
Expanding on David-SkyMesh's answer, making the first part mandatory, the second part of three alternatives optional:
/ ( # capture
(?:Completed: BALI - Job) # this
# AND optionally
# one of these
(?:\bBALI_(?:INVOICES|CORRESPONDENCE|LATE_SCANNINGS)\b)?
)
/x # ignore whitespace & comments in regexp itself
Upvotes: 1