Jump to content

StringSplit() - Anything else?


Recommended Posts

I.E .

$stringtest = "1+1=2,2+2=4,4+4=6"
$stringPrint = stringsplit($stringtest, "=")
msgbox(0,$stringtest,$stringPrint[2])

I would like the msgbox to return 2,2+2=4,4+4=6.

If this is not available can the mods move it to the idea lab forum?

Maybe make another flag:

$stringtest = "1+1=2,2+2=4,4+4=6"
$stringPrint = stringsplit($stringtest, "=",2)
msgbox(0,$stringtest,$stringPrint[2])

Where the flag 2 will put everthing into the second array.

If there is something else out there please disreguard request and show me the light - :D

EDIT change suggestion to idea lab

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

$string = "1+1=2,2+2=4,4+4=6"

$pos = StringInStr($string, "=")
If NOT @error Then MsgBox(64, "", '"' & StringTrimLeft($string, $pos) & '"')
I wish I knew how to code - If I did then I would have been able to figure this out and not wasted your time nor everyone elses. === Thanks for your help -

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

Probably what Helge meant would include the initial "=" sign in your string:

$string = "1+1=2,2+2=4,4+4=6"
$pos = StringInStr($string, "=")
If NOT @error Then MsgBox(64, "", '"' & StringTrimLeft($string, $pos - 1) & '"')
$desired_Result = StringTrimLeft($string, $pos - 1)

but this would have worked so you were on the right track:

$stringtest = "1+1=2,2+2=4,4+4=6"
$stringPrint = StringSplit($stringtest, "=")
If @error Then
    MsgBox(0, "Error", "No delimiter was found.")
Else
    Local $desired_Result = "="
    For $i = 2 To UBound($stringPrint) - 1
        $desired_Result &= $stringPrint[$i]
    Next
    MsgBox(0, $stringtest, $desired_Result)
EndIf

Don't you use SciTe (available at the AutoIt download site)? It leaves you with more readable syntax by using autocomplete and color-highlighting.

Edited by Squirrely1

Das Häschen benutzt Radar

Link to comment
Share on other sites

I would like the msgbox to return 2,2+2=4,4+4=6.

Maybe I misunderstood that sentence (:D), or maybe I just don't understand what

you are saying Squirrely1, because isn't my MsgBox showing exactly what he wanted..?

Link to comment
Share on other sites

  • Moderators

Maybe I misunderstood that sentence (:D), or maybe I just don't understand what

you are saying Squirrely1, because isn't my MsgBox showing exactly what he wanted..?

Well you know I have to throw my 2 cents in :wacko:

$string = "1+1=2,2+2=4,4+4=6"
$pos = StringMid($string, StringInStr($string, "=") + 1)
MsgBox(64, "", '"' & $pos & '"')
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

This is the most direct method :D

MsgBox(0, '', '2,2+2=4,4+4=6')
:wacko: MHz came with jokes!! :D

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

:D MHz came with jokes!! :wacko:

That's really funny. :D

So long,

Mega

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

Link to comment
Share on other sites

Maybe I misunderstood that sentence (:D), or maybe I just don't understand what

you are saying Squirrely1, because isn't my MsgBox showing exactly what he wanted..?

I'm not so sure of my untested code there Helge and you would have probably found some of what I did if you had given the topic more consideration (which might be more than it is worth). You must be referring to my amended version of your code. Instead of

If NOT @error Then MsgBox(64, "", '"' & StringTrimLeft($string, $pos) & '"')

it seemed you should subtract 1 from $pos to get the "=" in there:

If NOT @error Then MsgBox(64, "", '"' & StringTrimLeft($string, $pos - 1) & '"')

Also, I wanted to help the newbie see that what he had in mind could work. However, 4+4 in base 10 will never equal 6 unless the communists take over again in Yugoslavia.

Das Häschen benutzt Radar

Link to comment
Share on other sites

but this would have worked so you were on the right track:

$stringtest = "1+1=2,2+2=4,4+4=6"
$stringPrint = StringSplit($stringtest, "=")
If @error Then
    MsgBox(0, "Error", "No delimiter was found.")
Else
    Local $desired_Result = "="
    For $i = 2 To UBound($stringPrint) - 1
        $desired_Result &= $stringPrint[$i]
    Next
    MsgBox(0, $stringtest, $desired_Result)
EndIf
The code above does not work...the way it is now. I need to include the whole string from the delimiter to the end of the line. That is why I thought it might be a good idea to include another flag. But what I have works, but I think I like your idea. Anyway sorry about the string math, but it was a string, and yes I use Scite. Thanks for your time.

Edit - the string looks like this

DEFAULTURL=http://www.autoitscript.com/forum/index.php?act=post&do=edit_post&f=2&t=29405&p=210913&st=0

so I really do not need or want the first accuance, but everything afterwards

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...