0

index with regex

I'm trying to find a way to get the index (i.e. start position in a string) for a regex pattern. I can use text, replacex, extractx for various operations but not for getting the index, and the index function does no allow regex patterns.

5 replies

null
    • Sean
    • 3 mths ago
    • Reported - view

    You can use the extractx function in the index function. You can see an example of this here...

    https://forum.ninox.com/t/35hrtfc/extractx-g-flag-workaround

    • Ninox developper
    • Jacques_TUR
    • 3 mths ago
    • Reported - view

    You can do this in two stages: 

    extract text using a regular expression 

    find the position of the result text using the index function :

    var myText := "ABC123";
    var myRegExp := "\d+";
    var textResult := extractx(myText, myRegExp);
    var position := index(myText, textResult);
    myText + " | " + textResult + " | "+ position;
    

    return : ABC123 | 123 | 3

      • Sean
      • 3 mths ago
      • Reported - view

       You can also make it a one-liner...

      index("ABC123", extractx("ABC123", "\d+"))
      
    • Alain_Fontaine
    • 3 mths ago
    • Reported - view

    Or maybe:

    length(replacex(<your input string>, "<your regular expression>[^]*", ""))
    
    • Digital Humanities Researcher
    • Christoph.2
    • 3 mths ago
    • Reported - view

    Ah, smart, thanks! I did something similar, but way less efficient

Content aside

  • Status Answered
  • 3 mths agoLast active
  • 5Replies
  • 78Views
  • 4 Following