Extract certain variable numbers from attached file title
Hello everybody,
I'm working on an archive of graphics files.
I've imported preview graphics as images and extracted the title with this formula:
extractx(text(Preview), "(.+)\/(.+)", "i", "$2")
Each file is named like this
NAME-Nr001-200x400cm-Backlight-2021
Each number and text in this title is variable.
Is there a way to extract 001 , 200 and 400 in three different fields?
001 in field1 named "Numero intero"
200 in field2 named "Larghezza"
400 in field3 named "Altezza"
Each group of numbers can have from 1 to 4 numbers.
In any case, the first group of numbers will always go to field 1, the second to field 2, etc
Thanks for any help. Hope there is a solution
18 replies
-
Seems like you are comfortable with extractx so you would use that to find the correct sequence of numbers. I could never get the hang of regEx so I can’t post the code here.
Good luck
-
I guess I'm going to learn a bit of regex. :)
Try this in a formula field:
extractx("NAME-Nr001-200x400cm-Backlight-2021", "(\d+).(\d+).(\d+)", "", "$2")
You can replace the first text in quotes with your fieldname.
The second set of quotes is the regex expression. This code only works if there is one character between the first three number sets, i.e. in your example the second "-" and the first "x" work as would any other character/symbol. But if some names have multi-character then this breaks. Someone smarter than me can make the easy change to allow an unlimited amount of characters between. This regex creates three groups (001,200,400). Which you can use later.
The last set of quotes "$2", tells Ninox which group to display/use.
-
So now i'm on a regex kick. You can modify the regex part of the formula below to say:
extractx("NAME-Nr001-200x400cm-Backlight-2021", "(\d+)[^0-9]+(\d+)[^0-9]+(\d+)", "", "$2")
And now it will look for any non-digit character of any length between the groups of numbers.
-
I am speechless! You have all been really great and I am immensely grateful to you for making me learn something new and for finding a solution to my problem
With the following formula by @fred I immediately found myself very well
extractx("NAME-Nr001-200x400cm-Backlight-2021", "(\d+)[^0-9]+(\d+)[^0-9]+(\d+)", "", "$2")
But now I have one last "problem" that I hadn't thought of. The measurements in the file can also have millimeters.
For example 200x400cm could be "200,5x400,4cm". With this formula it shows the number before the "," but not the other one after it
How do I do in this case? The comma, if present in the title of the file, is inserted only and exclusively for the measures
-
Jacques TUR said:
Also, if you replace [^0-9]+ by ^[1-9]+, it's replace my (0*) and it stay only 3 groups (not 6) :I'm not sure why you started with 1 instead of 0.
-
Hi to all,
I've posted a new question about renaming part of the title using a button.
If you want take a look, maybe you can help me since you already know the formulas applied previously
https://forum.ninox.com/t/83hsagj/renaming-part-of-title-attachment
Regarding regular expressions, can someone recommend me a guide. I'm trying to figure out the formulas you sent me but I'm freaking out
Thank you :)
Content aside
- 1 yr agoLast active
- 18Replies
- 163Views
-
3
Following