Sign in to follow this  
Followers 0
edy

extract string

14 posts in this topic

hi all

I have a string like "10/6/04 7:59 AM" and i want to extract hours and minutes (7:59)

how can i obtain it?

Thanks

Share this post


Link to post
Share on other sites



Ok, Thanks

Share this post


Link to post
Share on other sites

To avoid keeping a unneeded array in memory you can change to:

$eg = "10/6/04 7:59 AM"
$time = StringSplit($eg, " ")
$time = $time[2]

MsgBox(4096, "Result", $time)

I love variants :)

Share this post


Link to post
Share on other sites

ezzetabi: Cute signature, but just as an FYI, you are missing a "1" at the end of your first binary string. It should be "001001001"

Share this post


Link to post
Share on other sites

I am guessing that means ezzitabi loves autoit?

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

$Nakoruru from what I see, but I was never into Binary.

ezzitabi loves autoit would roughly be:

01100101 01111010 01111010 01101001 01110100 01100001 01100010 01101001 00100000 01101100 01101111 01110110 01100101 01110011 00100000 01100001 01110101 01110100 01101111 01101001 01110100


AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

Wow, I never thought that someone actually tried to read it.

Ok... Time to change it :)

SerialKiller you are right, thanks.

Share this post


Link to post
Share on other sites

Geeze... I know that is Hex... (I think) I dont know how to read either hex or binary.. I would like to though... I just had to learn how to convert between the different numbering sceme's

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

I like the binary one for looks, but content of your new one is better. :)


AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

$example = "10/6/04 7:59 AM"

$time = StringSplit($example, " ")

MsgBox(4096, "Result", $time[2])

<{POST_SNAPBACK}>

I have tested using the StringSplit ($example, " ") -> which is empty space,

however it didn't work out to my case....

Example :

                    3300110025841204                  Name goes here                28,540

                    3300110025841385                  Name goes here                12,569

                    3300110025842854                  Name goes here                  5,874

For the above case... I wonder why the StringSplit() does not work ?

I've tested, it displays EMPTY by using MsgBox()

What I want is, to display 2 things:

1) a bunch of numbers (1st column)

2) name (2nd column)

Please advise. Thank you

Share this post


Link to post
Share on other sites

I have tested using the StringSplit ($example, " ") -> which is empty space,

however it didn't work out to my case....

Example :

For the above case... I wonder why the StringSplit() does not work ?

I've tested, it displays EMPTY by using MsgBox()

What I want is, to display 2 things:

1) a bunch of numbers (1st column)

2) name (2nd column)

Please advise. Thank you

<{POST_SNAPBACK}>

Each space will be returned as an element :

$example = "3300110025841204                  Name goes here                28,540"

$time = StringSplit($example, " ")

MsgBox(4096, "Result", $time[0])

MsgBox(4096, "Result", $time[37])

$time[0] is numer of elements (37)

the second msgbox display 28,540

bye

Share this post


Link to post
Share on other sites

Yea, you can have autoit clean up your code, and then output the data.

ex:

$x="                    3300110025841204                  Name_goes_here                28,540"
split($x)
$x="                    3300110025841385                  Name_goes_here                12,569"
split($x)
$x="                    3300110025842854                  Name_goes_here                  5,874"
split($x)

func split($_x)
$_xarray=Stringsplit($_x," ")
for $i=1 to $_xarray[0]
if $_xarray[$i]="" then continueloop
msgbox(1,$_xarray[$i],"")
next    
endfunc

since you stringsplit by space, then "Name goes here" would cause a problem.

If you have a lot of this data, I would use something with regular expressions. It can make 2-20 spaces into say a | and then you could just stringsplit by |.

Use autoit to run a command line version or have autoit run it's GUI. I do that a lot with XML data. :)


AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

thanks guys for the tips and helps !

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