Sign in to follow this  
Followers 0
disney

Split string (An easy question, i think?)

5 posts in this topic

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

Share this post


Link to post
Share on other sites



you say it, it easy question :)

StringMid("Open 2008-05-01 12:28 by Hans Zettberg/AVDL/RITTS",6,16)


[center]uqoii.nl[/center]

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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])

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0