Notifications
Clear all

[Closed] filter string for version number

Filtering a string based on its characters.
I want to filter a string up to _v###
so i’d like a way to filter a string of any kind using a format like this
“underscore + letter + number + number + number + underscore”

obviously this does not work

filterstring "donut_Violin_v005_cool25" "_*###_"

which i want it to return “v005” and then I can just do ‘as integer’ to get the number.

I’m open to any ideas someone may have for a better solution. All I’m looking to do is get the version number of the file.

2 Replies
1 Reply
(@gazybara)
Joined: 11 months ago

Posts: 0
str = "_"+(filterstring "donut_Violin_v005_cool25" "_")[3]+"_"
fn getVersion str =
(
	local cnt = 0,idx = 0
	while cnt != 2 or idx == undefined do
	(
		idx = findString str "_" ; cnt += 1
		str = if cnt == 1 then substring str (idx+1) str.count
		else substring (substring str (idx) str.count) 1 6
	)
)
str = "donut_Violin_v005_cool25"
getVersion str