Options

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

sgnarkhede2016sgnarkhede2016 Member Posts: 152 Contributor II
edited May 2023 in Help
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

Answers

  • Options
    jwpfaujwpfau Employee, Member Posts: 278 RM Engineering
    edited May 2023
    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,
    Jonas
  • Options
    sgnarkhede2016sgnarkhede2016 Member Posts: 152 Contributor II
    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, 2022
    Getting : Apr 24, 2022-Apr 30, 2022,Jan 01, 2022-Jan 30, 2022,Jun 26, 2022-Jun 30, 2022

    regex: ([^+^,]+,)+[^+^,]+\+(?!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 this
  • Options
    jwpfaujwpfau Employee, Member Posts: 278 RM Engineering
    edited May 2023
    This should work
    ([^+^,]+,)+[^+^,]+\+(?!Delay)[^,]+,?|(\+Delay,(?!.*\+Delay))|\+Delay
    (make sure to remove additional whitespaces after pasting)
  • Options
    Eden60Eden60 Member Posts: 7 Contributor II
    To extract the dates containing the "Early" keyword using regular expressions (regex) from the given data, you can use the following regex pattern:

    \b(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{1,2},\s\d{4}-\b.*?Early\b 

    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".
    I hope this will help you.

    Regards
    Eden Wheeler
Sign In or Register to comment.