Extract Date Part that contain Early KeyWord using regex (replace operator)

sgnarkhede2016
New Altair Community Member
From below data extract the date that contains Early keyword using regex
Apr 24, 2022-Apr 30, 2022+Early,Jun 16, 2022-Jun 30, 2022+Delay,Jun 23, 2022-Jun 30, 2022+NA,Jun 26, 2022-Jun 30, 2022+Early
Output:Apr 24, 2022-Apr 30, 2022,Jun 26, 2022-Jun 30
Apr 24, 2022-Apr 30, 2022+Early,Jun 16, 2022-Jun 30, 2022+Delay,Jun 23, 2022-Jun 30, 2022+NA,Jun 26, 2022-Jun 30, 2022+Early
Output:Apr 24, 2022-Apr 30, 2022,Jun 26, 2022-Jun 30
Tagged:
0
Answers
-
Hi,
This is way easier with the matches method of the Generate Attributes operator.
But if you really want to replace the non matching part, you should read about negative lookahead.([^+^,]+,)+[^+^,]+\+(?!Early)[^+^,]+,?|(\+[^+^,]+)
Greetings,
Jonas0 -
Thanks, But it not working for me fully
Input : Apr 24, 2022-Apr 30, 2022+Early,May 16, 2022-May 30, 2022+Delay,Jan 01, 2022-Jan 30, 2022+Early,Jun 26, 2022-Jun 30, 2022+NA
regex: ([^+^,]+,)+[^+^,]+\+(?!Early)[^,]+,|\+[^,]+Early Expected : Apr 24, 2022-Apr 30, 2022,Jan 01, 2022-Jan 30, 2022Getting : Apr 24, 2022-Apr 30, 2022,Jan 01, 2022-Jan 30, 2022,Jun 26, 2022-Jun 30, 2022regex: ([^+^,]+,)+[^+^,]+\+(?!Delay)[^,]+,|\+[^,]+Delay Expected: May 16, 2022-May 30, 2022
Delay :May 16, 2022-May 30, 2022,Jun 26, 2022-Jun 30, 2022
Can you please help me on this0 -
This should work
([^+^,]+,)+[^+^,]+\+(?!Delay)[^,]+,?|(\+Delay,(?!.*\+Delay))|\+Delay
(make sure to remove additional whitespaces after pasting)0 -
\b(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{1,2},\s\d{4}-\b.*?Early\bTo extract the dates containing the "Early" keyword using regular expressions (regex) from the given data, you can use the following regex pattern:
Here's how this regex pattern works:
\b
: This is a word boundary anchor to ensure that we match whole words.(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)
: This part matches the abbreviated month names (e.g., Apr, Jun).\s
: Matches a single whitespace character.\d{1,2},\s\d{4}-
: Matches the date in the format "dd, yyyy-" (e.g., "24, 2022-")..*?
: Matches any characters (non-greedy- blue prism).Early
: Matches the keyword "Early".
Regards
Eden Wheeler0