Jump to content

How can do newline StringSplit?


Codemike
 Share

Recommended Posts

Try something like this:

#include <Array.au3>
$t = ClipGet()
$aT = StringSplit(StringReplace($t, Chr(13), ""), Chr(10), 2)
Dim $aFinal[UBound($aT)][100000]
$ub = 0
For $h = 0 To UBound($aT) - 1
    $array = StringSplit($aT[$h], "", 2)
    If $ub < UBound($array) Then $ub = UBound($array)
    For $i = 0 To UBound($array) - 1
        $aFinal[$h][$i] = $array[$i]
    Next
Next
ReDim $aFinal[UBound($aT)][$ub]
_ArrayDisplay($aFinal)

This is just a simple example and has enough room for improvement.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Try something like this:

#include <Array.au3>
$t = ClipGet()
$aT = StringSplit(StringReplace($t, Chr(13), ""), Chr(10), 2)
Dim $aFinal[UBound($aT)][100000]
$ub = 0
For $h = 0 To UBound($aT) - 1
    $array = StringSplit($aT[$h], "", 2)
    If $ub < UBound($array) Then $ub = UBound($array)
    For $i = 0 To UBound($array) - 1
        $aFinal[$h][$i] = $array[$i]
    Next
Next
ReDim $aFinal[UBound($aT)][$ub]
_ArrayDisplay($aFinal)

This is just a simple example and has enough room for improvement.

Br,

UEZ

Thanks, but I'm a beginner in the programming and I have tryed much think how I can continue that I get words that original form without words merge (and can use example $word[x] call)?
Link to comment
Share on other sites

If you replace line 7 with

$array = StringSplit($aT[$h], " ", 2)

it will split at space.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • Moderators

This is one of those times where you've attempted to follow the forum rules, and the translation is getting lost I think.

I'd suggest you posting your question in your native language now. Maybe someone that speaks it will understand.

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

Codemike,

I believe the problem (and solution) is very simple. You are splitting the text on the spaces and the @CRLF at the end of each line is not splitting.

Just use StringReplace to change the @CRLF to spaces and the StringSplit works as you wish: ;)

#include <Array.au3>

$sText = "This is line 1" & @CRLF & _
         "This is line 2" & @CRLF & _
         "This is line 3" & @CRLF & _
         "This is line 4"

$aStringSplit = StringSplit(StringReplace($sText, @CRLF, " "), " ")

_ArrayDisplay($aStringSplit)

Is that what you wanted? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

The way I'd do it Melba is use StringStripCR and then use the fact that StringSplit accepts multiple splits... You might also want to treat double spaces as being one:

#include <Array.au3>

$sText = "This is line 1" & @CRLF & _
         "This is line 2" & @CRLF & _
         "This is line 3" & @CRLF & _
         "This is line 4"

$aStringSplit = StringSplit(StringStripWS(StringStripCR($sText), 4), " " & @LF)

_ArrayDisplay($aStringSplit)

Just a few more things to think about :)

Mat

Link to comment
Share on other sites

The way I'd do it Melba is use StringStripCR and then use the fact that StringSplit accepts multiple splits... You might also want to treat double spaces as being one:

#include <Array.au3>

$sText = "This is line 1" & @CRLF & _
         "This is line 2" & @CRLF & _
         "This is line 3" & @CRLF & _
         "This is line 4"

$aStringSplit = StringSplit(StringStripWS(StringStripCR($sText), 4), " " & @LF)

_ArrayDisplay($aStringSplit)

Just a few more things to think about :)

Mat

Thanks very much evryone who help me. Yes now it works what I need.

#include <Array.au3>

clipget()

$sText = clipget()

$aStringSplit = StringSplit(StringReplace($sText, @CRLF, " "), " ")

_ArrayDisplay($aStringSplit)

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...