0

Please fix the extract() function so flags will work

6 replies

null
    • Sean
    • 4 yrs ago
    • Reported - view

    I can't help myself 馃槇. Why would you use "i" or case insensitive mode when you are only extracting numbers?

    • Sean
    • 3 yrs ago
    • Reported - view

    How do you avoid fixing something in version 2.7? 馃

    • Frank_Bohmer
    • 3 yrs ago
    • Reported - view

    Hi Sean, I think the function works just fine. Do you have a specific example? E.g.

    extractx("Hello", "[a-z]+", "", "Result: $0") => "Result: ello"

    extractx("Hello", "[a-z]+", "i", "Result: $0") => "Result: Hello"

    Best, Frank

    • Sean
    • 3 yrs ago
    • Reported - view

    Hi Frank, here is an example...

     

    let myVar := "ABC123DEF456";
    extractx(myVar, "\D+", "g", "$0")

     

    If it worked similarly to Javascript match(), it would return "ABCDEF" because of the global flag.

    • Frank_Bohmer
    • 3 yrs ago
    • Reported - view

    The purpose of extractx is to retrieve the (first) matching part of the string, not the not-matching part. \D+ matches the digits.

    • Sean
    • 3 yrs ago
    • Reported - view

    Hi Frank,

     

    Then there is no point in having flags in the function. The global flag works in the replacex function. I had the impression the functions with "x" at the end were Regex functions. If that's the case, then the "g" or global flag would cause the function to match all the characters in the string that are not numbers in this example.

     

    Gr眉脽e Sean

Content aside

  • 3 yrs agoLast active
  • 6Replies
  • 1285Views