Jump to content

Extract some infos from a string


pollop
 Share

Recommended Posts

Hi :D

I'm trying to get some informations from a text but i have some problems doing it :/

Here's is the string contained in a variable :

10:59 / 41:37
Frame-rate
24.89 (1X)
Sync Offset
avg: 0 ms, dev: 5 ms
Frames
drawn: 384, dropped: 1
Jitter
3 ms
Buffers
[0]: 1153/4267 KB [1]: 1895/854 KB (p0)
Bitrate
[0]: 600/348 Kb/s [1]: 159/153 Kb/s (avg/cur)
Shader Editor
Shader Editor
Delete
Subresync
Playlist
Playlist
Capture Settings
Capture Settings
...

What i'm trying to do is to extract the "10:59" and "41:37" into two variables...

( If the runtime is more than an hour, it's in three parts : "01:25:11")

How can i extract the text until the carriage return ?

Thanks.

Pollop

PS : Sry for my poor english, i'm doing my best :huggles:

Edited by pollop
Link to comment
Share on other sites

$text = "10:59 / 41:37" & @CRLF & "Frame-rate"
$lines = StringSplit($text, @CRLF, 1)
$line1 = $lines[1]
$vars = StringSplit($line1, " / ", 1)
MsgBox(0,'Result', "variable 1: " & $vars[1] & @CRLF & "variable 2: " & $vars[2])

Thanks a lot for your help !

How can i be sure that it's a @CRLF and not a @LF ou @CR :/

Will there be a problem if i use @CRLF and if it's a @LF ?

Thanks :D

Link to comment
Share on other sites

How can i be sure that it's a @CRLF and not a @LF ou @CR :/

Will there be a problem if i use @CRLF and if it's a @LF ?

It's easy :-)

$text = "10:59 / 41:37" & @CRLF & "Frame-rate"
$text = StringReplace($text, @CRLF, @LF)
$text = StringReplace($text, @CR, @LF)
$lines = StringSplit($text, @LF, 1)
$line1 = $lines[1]
$vars = StringSplit($line1, " / ", 1)
MsgBox(0,'Result', "variable 1: " & $vars[1] & @CRLF & "variable 2: " & $vars[2])
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...