0

Regular expression Syntax in Ninox

I asked Chat GPT  "regular expression for eliminating numbers after a comma in Ninox database", and I believe the answer is wrong. I'm familiar with regular expressions; I usually apply them on Numbers and Excel but I do not know how to apply them on Ninox.

My (failed) procedure has been as follows:

1) I'm on a table and I'm applying a "Formula" with the button "fx Formula"

2) I then get the pop-up screen that lets me give a name to the field, give it some style, apply an "On click" rule, etc.

3= I then  click on the "Formula" field's button and, considering that "PRICE" is the name of a field,  I type the following:

let cleanedText := replaceAll(PREU, ",.*$", "");
cleanedText

This syntax is completely wrong. I have tried other things like:

extractx(PRICE),\d+

I could not find the syntax for Ninox at all.

Can anyone help?

8 Antworten

null
    • Kruna
    • vor 5 Monaten
    • Gemeldet - anzeigen

    Hi videodossier, I hope I got you right with what you would like to achieve. Assuming that the PRICE field is a number field (works also with fx field) you just need to click here at Zahlenformat, then a window pops up where you can define what should happen after the comma.

    • mirko3
    • vor 5 Monaten
    • Gemeldet - anzeigen

    The solution for your problem with regular expression is (brain used)

    extractx(TEXT, "\d+(?=,\d+)")

    or

    replacex(TEXT, ",\d+")

    but the idea from Kruna is better. Mirko

    • videodossier
    • vor 5 Monaten
    • Gemeldet - anzeigen

    Hello, 

    The solution from Kruna does not suit my needs because of what I want to do. I nevertheless tried it and I thank you very much, Kruna.

    I actually want to take what is behind the coma on  the value of a price field. So, if the price is 72 I want a field with a formula that will be automatically filled with "0". And if the price is 72,35 the field will be filled with "35".

    I have tried, the solutions from Mirko but none of the syntax is right. I replace "TEXT" by the name of the field where the price is but it Ninox won't accept the syntax. This is what bothers me. I have not found clear documentation on how to apply RegEx syntax in the Formula's Text environment.

    Any more ideas? Thank you so much, Mirko!

    • mirko3
    • vor 5 Monaten
    • Gemeldet - anzeigen

    The problem could be the field types. Regex in Ninox is for text() and your field could be a number field. So the value must first be converted. My code is also wrong, because I assumed that you need the number before the decimal point. Try this. Mirko

    item(split(text(PREU), ","), 1)
    

    or

    replacex(text(PREU), "\d+,", "")
    
    • mirko3
    • vor 5 Monaten
    • Gemeldet - anzeigen

    I read your text again. If your field is a number field and reflects a price, then it should work that way.

    (PRICE * 100) % 100
    

    This will give you the decimal value after the decimal point, i.e. the cent amount

      • videodossier
      • vor 5 Monaten
      • Gemeldet - anzeigen

       Hello, Mirko. I do not exactly understand why this is working. But it perfectly works. Thank you very much. I'll try to study about how this % 100 is actually working.

      Thanks so much; really, thanks so much!

      • mirko3
      • vor 5 Monaten
      • Gemeldet - anzeigen

       % is an operator called modulo, like plus or minus. It gives you the remainder after a division of integers. Since the decimal places in prices are never more than two, I multiply by 100 beforehand, i.e. 12.45 becomes 1245 and then I divide (modulo) by 100 and the remainder is 45. Mirko

    • T_Bartzsch
    • vor 5 Monaten
    • Gemeldet - anzeigen
     said:
    I asked Chat GPT  "regular expression for eliminating numbers after a comma in Ninox database", and I believe the answer is wrong.

     ChatGPT is not able to give the right answer for NINOX Script. It always gives you javascript or something like this... 

Content aside

  • vor 5 MonatenZuletzt aktiv
  • 8Antworten
  • 93Ansichten
  • 4 Folge bereits