Page 1 of 1
[solved] $Regext() for multiple numbers
Posted: Wed Jun 12, 2019 9:53 am
by ThomasM
Hi there,
here is another one.
I have a .TXT-File only containing one line: TAG:timecode=02:12:34:23
I want to populate a Variable using $regext($read("%s_original_path%\Timecode.TAG"),"(\d+)") in populate variables node, but it only gives me the first two digits (in this case 02).
How can I retrieve all eight numbers for a string looking like 02123423 ?
Thanks in advance,
thomas
Re: $Regext() for multiple numbers
Posted: Wed Jun 12, 2019 11:34 am
by emcodem
Hi Thomas!
"\d+" means "the first number in the string plus any following number" - it does not work for your case because ":" is not a number.
The following means: "start from = and take everything up to the line end ($)"
Notice that the parenthesis () are for defining that we do not want to include the = Symbol itself.
A common Special tipp: in regex i mostly use this sequence "START(.+?)END"... it means match anything between... E.g. for XML parsing:
cheers!
Re: $Regext() for multiple numbers
Posted: Wed Jun 12, 2019 11:44 am
by momocampo
Hello Thomas,
Well, emcodem was, as usual, quicker as I but you can also do with "classic" populate variable like this :
- populate.JPG (46.9 KiB) Viewed 8252 times
You will obtain only your number.
Cheers.
Benjamin
Re: $Regext() for multiple numbers
Posted: Wed Jun 12, 2019 12:02 pm
by janciev
Hi,
please try
It works here.
Cheers,
Igor
Re: $Regext() for multiple numbers
Posted: Wed Jun 12, 2019 1:08 pm
by emcodem
janciev wrote: ↑Wed Jun 12, 2019 12:02 pm
please try
Take care, the "^" (when used in brackets) means do NOT match (otherwise it means start of line), so this regex means do not match numbers.
Sorry i did not see that the ":" should not be included in the result. This should do it:
cheers!
emcodem
Re: $Regext() for multiple numbers
Posted: Wed Jun 12, 2019 1:23 pm
by janciev
Hi,
indeed that was inverted logic!
Thanks for correcting!
Igor
Re: $Regext() for multiple numbers
Posted: Wed Jun 12, 2019 2:39 pm
by ThomasM
Hi all,
thank you for your help - helps here in the archive a lot reading out log-files.
@emcodem,
works***per***fect***ly. Thank you!
@Momocampo
Nice idea. I will have a look at these functions. Thanks!
@Jnaciev,
yeah - I tried that also and broke. But anyway - Thank you too!
all the best,
tom