find group of machting characters



  • Hello,

    I would like to use a RegEx to find a group of machting characters

    string example:
    2020-04-30T14:17:41.581Z <PLC0040:[STX/2]4110168 200001742340020110400201914002019101

    this string contains twice : 40020191

    but the value of the characters may vary, so instead of the example the following is also possible 12345678.

    When the group of characters is known i use:

    (?-s)(?i)40020191.*40020191
    

    But now it needs to be more generic. So only looking for a duplication of a group of 8 characters in a string.

    How can i do this?

    Thanks in advance!
    Boris



  • @bowoo-king

    I certainly might be inclined to try (?-s)(\d{8}).*?\1



  • @bowoo-king said in find group of machting characters:

    duplication of a group of 8 characters in a string

    The example showed digits so that’s what my solution was tailored to.
    But…
    If it is truly “characters” then this might be more appropriate:
    (?-s)(.{8}).*?\1


Log in to reply