aescribens
asked on
Extracting Value from String
Hello Experts,
How can I extract certain values from a string?
For example, I have the following string...
version: 51.9.0 built on Feb 12 2007 12:01:35, gcc: 3.4.5 (mingw special) Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 25.00 (25/1) Input #0, flv, from 'c:\videos\testvideo.flv': Duration: 00:04:19.1, start: 0.000000, bitrate: 64 kb/s Stream #0.0: Video: flv, yuv420p, 320x240, 25.00 fps(r) Stream #0.1: Audio: mp3, 22050 Hz, mono, 64 kb/s
Now, I need to extract the following values...
flv (which is always next to Video: )
00:04:19.1 (which is always next to Duration: )
I tried the following:
<cfset duration_ = #listgetat(result,55," ")#>
<cfif right(duration_, 1) is ",">
<cfset duration_ = left(duration_, len(duration_)-1)>
</cfif>
But the problem is that the order of the word count changes constantly and I get different results, so I think the safest way to do this is to target the values next to the keywords (Duration, Video).
Thanks!
Anthony
How can I extract certain values from a string?
For example, I have the following string...
version: 51.9.0 built on Feb 12 2007 12:01:35, gcc: 3.4.5 (mingw special) Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 25.00 (25/1) Input #0, flv, from 'c:\videos\testvideo.flv':
Now, I need to extract the following values...
flv (which is always next to Video: )
00:04:19.1 (which is always next to Duration: )
I tried the following:
<cfset duration_ = #listgetat(result,55," ")#>
<cfif right(duration_, 1) is ",">
<cfset duration_ = left(duration_, len(duration_)-1)>
</cfif>
But the problem is that the order of the word count changes constantly and I get different results, so I think the safest way to do this is to target the values next to the keywords (Duration, Video).
Thanks!
Anthony
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're welcome :)
ASKER
agx: I have a follow-up question... What if I need to extract only the Email portion from the following string: John <jdoe@gmail.com>
How would I do that?
How would I do that?
Hi @aescribens - I see you got an answer already here https://www.experts-exchange.com/questions/26282914/Parsing-and-Extracting-Value-from-String.html?cid=1576
BTW: It's usually better to open a new question because many experts stop monitoring questions after they're answered. I just happened to still be monitoring this one :)
BTW: It's usually better to open a new question because many experts stop monitoring questions after they're answered. I just happened to still be monitoring this one :)
ASKER
Yes I noticed. :) Thanks.
ASKER