Skip to main content
Inspiring
May 5, 2026
Question

how to extract the id's from the text

hi team,

testing the emailid's,1234567-45 testing 1234567-9ow2 doing 12 34 567- 2 2 test 12/34,567:- 2.2 tests 12345an67-92 dummy 12345-23 

have to extract the id's and after extracting need to format in below format,

12345-05,

123456-06

1234567-07

could you please suggest best approch.

    6 replies

    harshas2775
    Brainy
    May 5, 2026

    Can you give better example of the email id and expected output. How "1234567-45 testing 1234567-9ow2 doing 12 34 567- 2 2 test 12/34,567:- 2.2 tests 12345an67-92 dummy 12345-23 " becomes the below , I cant make sense of it

    12345-05,

    123456-06

    1234567-07

    Happy to help. Even happier to optimize.
    Inspiring
    May 5, 2026

    hi [mention:65b14048184a4eb5aff3a76c87b97431:e9ed411860ed4f2ba0265705b8793d05] , In the email will get the input like "testing the emailid's,1234567-45 testing 1234567-9ow2 doing 12 34 567- 2 2 test 12/34,567:- 2.2 tests 12345an67-92 dummy 12345-23 "

    need to extract the ID's from text after extracting id's then we have to truncate the spaces /alpha letters/special characters then need to format below .

    12345-05,

    123456-06

    1234567-07

    harshas2775
    Brainy
    May 5, 2026

    Your text will be this after removing special characters and alphabets. "1234567-45 1234567-92 12 34 567- 2 2 1234567- 22 1234567-92 12345-23" 
    Still not sure on what basis 12345-05, 123456-06, 1234567-07 series will come along. 
    Give this code a try as a starter and then apply logic to get the desired series. The output format/logic is unclear to me, so I will leave it till this for you. 

    a!localVariables(
      local!text: "testing the emailid's,1234567-45 testing 1234567-9ow2 doing 12 34 567- 2 2 test 12/34,567:- 2.2 tests 12345an67-92 dummy 12345-23",
      reject(
        fn!isnull,
        split(
          stripwith(
            local!text,
            "abcdefghijklmnopqrstuvwxyz!@#$%^&*();',./<>?:"
          ),
          " "
        )
      )
    )


    Happy to help. Even happier to optimize.
    shubhama926776
    Brainy
    May 5, 2026

    Could you share your actual input and the expected output for the same input?

    शुभम्
    Inspiring
    May 5, 2026

    input: testing the emailid's,1234567-45 testing 1234567-9ow2 doing 12 34 567- 2 3 test 12/34,567:- 2.2 tests 12345an67-92 dummy 12345-23 

    output:1234567-45,1234567-92,1234567-23,1234567-22,1234567-92

    shubhama926776
    Brainy
    May 5, 2026

    Check this :
    Also, you might have missed the last 12345-23 from the output. As per my understanding, it is a valid Id.
    Check if the Regex plugin is deployed in the environment to access regex functions.
    Regular Expression Functions

    a!localVariables(
      local!input: "testing the emailid's,1234567-45 testing 1234567-9ow2 doing 12 34 567- 2 3 test 12/34,567:- 2.2 tests 12345an67-92 dummy 12345-23",
    
      local!cleaned: regexreplaceall("[^0-9\-]", local!input, ""),
    
      local!ids: regexallmatches("\d{5,7}-\d{2}", local!cleaned),
    
      local!ids
    )

    शुभम्