[solved] $Regext() for multiple numbers

Questions and answers on how to get the most out of FFAStrans
Post Reply
ThomasM
Site Admin
Posts: 224
Joined: Wed Feb 22, 2017 6:36 am

[solved] $Regext() for multiple numbers

Post 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
Last edited by ThomasM on Fri Jun 14, 2019 10:36 am, edited 1 time in total.
emcodem
Posts: 1643
Joined: Wed Sep 19, 2018 8:11 am

Re: $Regext() for multiple numbers

Post 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 ($)"

Code: Select all

=(.+?)$
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:

Code: Select all

<tag>(.+?)</tag>
cheers!
emcodem, wrapping since 2009 you got the rhyme?
momocampo
Posts: 592
Joined: Thu Jun 08, 2017 12:36 pm
Location: France-Paris

Re: $Regext() for multiple numbers

Post 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
populate.JPG (46.9 KiB) Viewed 7369 times
You will obtain only your number.

Cheers.

Benjamin
janciev
Posts: 10
Joined: Sun Jun 02, 2019 10:37 am

Re: $Regext() for multiple numbers

Post by janciev »

Hi,

please try

Code: Select all

 [^\d]

It works here.

Cheers,
Igor
emcodem
Posts: 1643
Joined: Wed Sep 19, 2018 8:11 am

Re: $Regext() for multiple numbers

Post by emcodem »

janciev wrote: Wed Jun 12, 2019 12:02 pm please try

Code: Select all

 [^\d]
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:

Code: Select all

(\d+):(\d+):(\d+):(\d+)
cheers!
emcodem
emcodem, wrapping since 2009 you got the rhyme?
janciev
Posts: 10
Joined: Sun Jun 02, 2019 10:37 am

Re: $Regext() for multiple numbers

Post by janciev »

Hi,

indeed that was inverted logic! :oops: Thanks for correcting!

Igor
ThomasM
Site Admin
Posts: 224
Joined: Wed Feb 22, 2017 6:36 am

Re: $Regext() for multiple numbers

Post 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
Post Reply