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
-
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.
-
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
-
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!
-
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+,", "")
-
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
-
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 3 MonatenZuletzt aktiv
- 8Antworten
- 83Ansichten
-
4
Folge bereits