I do not see what is messed up. It looks like it gave the desired results.
Original Message:
Sent: 12-22-2023 17:01
From: Dalton Paul
Subject: Parsing Data Via Scripting
Upon further testing, I realized the longer my data (xxxxxxxxxxxxxxxxx (yyyyyyy) (11-22, 3:33)) gets the more messed up it becomes. How would you adjust it if the text was something along the lines of:
New Data Example: F. PlayerName 18 yard Touchdown, pass from S. PlayerName (T. PlayerName kick is good) (11:22, 3:33)
text1: F. PlayerName 18 yard Touchdown, pass from S. PlayerName (T. PlayerName kick is good)
text2: 11
text3: 22
text4: 3:33
------------------------------
Dalton
Senior Graphics Producer
------------------------------
Original Message:
Sent: 12-07-2023 14:30
From: Azathoth Son of Cthulhu
Subject: Parsing Data Via Scripting
Did a quick test and this worked. You want Regular Expressions. Very Powerful.
https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference
First, add this to your Global Scripts.
Function RegExpReplace(src as String, rgx as String, rplc as String) Dim rObj as Object Dim rez as String rObj = CreateObject("VBScript.RegExp") rObj.Pattern = rgx rObj.Global = True rez = rObj.Replace(src,rplc) RegExpReplace = rezEnd Function
Then I put this in the "On Prepare" event.
Dim src as xpTextObject, txt as xpTextObjectSelf.GetObjectByName("src",src)Self.GetObjectByName("Text1",txt)txt.Text=RegExpReplace(src.Text,"^([^\)]*\)).*","$1")Self.GetObjectByName("Text2",txt)txt.Text=RegExpReplace(src.Text,"^.*\([ ]*([\d]*).*","$1")Self.GetObjectByName("Text3",txt)txt.Text=RegExpReplace(src.Text,"^.*\([ ]*[\d]*-([\d]*).*","$1")Self.GetObjectByName("Text4",txt)txt.Text=RegExpReplace(src.Text,"^.*\(.*,[ ]*([^\)]*).*","$1")
Assuming that format never changes, this should work.
------------------------------
Azathoth
Son of Cthulhu