Jump to content

Sort txt file line by line


Recommended Posts

http://www.****.com/123.php?id=5|http://www.***.com/services/123.php?id=16|http://www.123.com/questions/q.php?id=5|http://123.com/researcher/view_group.php?id=995|http://www.123.com/en/contest/|http://www.123.com/club/123.php?id=77|

How can I sort a file like this in to a line by line .txt file?

Link to comment
Share on other sites

Like this:
 

Local $sContent = "http://www.****.com/123.php?id=5|http://www.***.com/services/123.php?id=16|http://www.123.com/questions/q.php?id=5|http://123.com/researcher/view_group.php?id=995|http://www.123.com/en/contest/|http://www.123.com/club/123.php?id=77|"
Local $NewContent, $aArray = StringSplit($sContent, "|")
For $i = 1 To UBound($aArray) - 1
    $NewContent &= $aArray[$i] & @CRLF
Next
FileWrite(@ScriptDir & "\textfile.txt", $NewContent)

 

Edited by Trong
$i = 0 => $i = 1

Regards,
 

Link to comment
Share on other sites

assuming the OP does not mean to "sort" (as in alphabetical order or some other order), then

$sNewContent = StringReplace($sContent, '|', @CRLF)

 

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

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

×
×
  • Create New...