disney Posted May 7, 2008 Posted May 7, 2008 Hello! I think this is a easy question? The goal is to just get the date from this string. I want to split this string: "Open 2008-05-01 12:28 by Hans Zettberg/AVDL/RITTS" I managed to get the "Open" in the beginning by writing: StringTrimLeft($calldate, 5) But the problem is that the other part dosent have a fixed chars count. The first part is always 5 chars. "Open " but the last part " 12:28 by Hans Zettberg/AVDL/RITTS" can be diffrent for exemple: " 12:28 by Hassefels Deflindogro /ADDS/RISSST" The best thing would be to cut the string after 10 chars. So i finally only get the date. I'm sure that this problem have a simple solution, but i don't know it. Thanks from Hans / Sweden
UQOII Posted May 7, 2008 Posted May 7, 2008 you say it, it easy question StringMid("Open 2008-05-01 12:28 by Hans Zettberg/AVDL/RITTS",6,16) [center]uqoii.nl[/center]
Xenobiologist Posted May 7, 2008 Posted May 7, 2008 Global $string = "Open 2008-05-01 12:28 by Hans Zettberg/AVDL/RITTS" $re = StringRegExp($string, '[\d*-]+.*\d\d:\d\d', 3) ConsoleWrite($re[0] & @CRLF) Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
Greenhorn Posted May 7, 2008 Posted May 7, 2008 Hi, $sString1 = 'Open 2008-05-01 12:28 by Hans Zettberg/AVDL/RITTS' $sString2 = 'Open 2008-05-01 12:28 by Hans Zettberg/AVDL/RITTS' & @CRLF & _ 'Open 2008-05-01 12:28 by Hassefels Deflindogro /ADDS/RISSST' ; for single line. $aStringParts = StringRegExp($sString1, '(\w*?\s\d*-\d*-\d*)|(\d*:\d*\s.*\r?)', 3) MsgBox(266304, Default, 'First part of the string is: ' & $aStringParts[0] & @CRLF & _ 'Second part of the string is: ' & $aStringParts[2]) ; for multi line. $aStringParts = StringRegExp($sString2, '(\w*?\s\d*-\d*-\d*)|(\d*:\d*\s.*\r?)', 3) MsgBox(266304, Default, 'First part of the 1st line is: ' & $aStringParts[0] & @CRLF & _ 'Second part of the 1st line is: ' & $aStringParts[2] & @CRLF & @CRLF & _ 'First part of the 2nd line is: ' & $aStringParts[3] & @CRLF & _ 'Second part of the 2nd line is: ' & $aStringParts[5])
disney Posted May 7, 2008 Author Posted May 7, 2008 you say it, it easy question StringMid("Open 2008-05-01 12:28 by Hans Zettberg/AVDL/RITTS",6,16)Thanks UQOII!Worked out fine!!!/Hans
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now