Jump to content

Count equal strings in substring


Recommended Posts

Hello,

I have a file with a suite of numbers like this :

t1t4t2t89t3t27t1s23t2s91t3s46|t1t22t2t38t3t217t1s52t2s11t3s60|t1t121t2t194t3t44t1s73t2s158t3s84|....

And I want to count each string "t1t***", "t2t***", "t3t***", "t1s***", "t2s***" and "t3s***" in each part between "|".

For example :

$string = "t1t4t2t89t3t27t1s23t2s91t3s46|t1t22t2t38t3t217t1s52t2s11t3s60|t1t121t2t194t3t44t1s73t2s158t3s84|"

$t1t = "121"

$t2t = "22"

$t3t = "27"

$t1s = "52"

$t2s = "11"

$t3s = "46"

(This variables changes.)

And I want to count each variable ($t1t, $t2t, ... $t3s) in each part between "|" ("t1t4t2t89t3t27t1s23t2s91t3s46" and "t1t22t2t38t3t217t1s52t2s11t3s60" and "t1t121t2t194t3t44t1s73t2s158t3s84")

And the function return "1" if it has find 3 variables of 6, return "2" if it has find 4 variables, return "3" if it has find 5 variables, return "4" if it has find 6 variables in a part between "|".

Qui ose gagneWho Dares Win[left]CyberExploit[/left]

Link to comment
Share on other sites

what will hapend if you have line like this, do you have line like this ? "t1t2t2t3t3t27t1s23t2s91t3s46" will it need to count t1t or t2t in that case and did you try to count them with stringsplit? Eg:

$st = StringSplit("t1t4t2t89t3t27t1s23t2s91t3s46|t1t22t2t38t3t217t1s52t2s11t3s60|t1t121t2t194t3t44t1s73t2s158t3s84","|")
For $x = 1 to $st[0]
    $1 = StringSplit($st[$x],"t1t",1)
    $2 = StringSplit($st[$x],"t2t",1)
    $3 = StringSplit($st[$x],"t3s",1)
    $4 = StringSplit($st[$x],"t1s",1)
    $5 = StringSplit($st[$x],"t2s",1)
    $6 = StringSplit($st[$x],"t3s",1)
    MsgBox(0,"",$1[0]-1&" "&$2[0]-1&" "&$3[0]-1&" "&$4[0]-1&" "&$5[0]-1&" "&$6[0]-1)
Next

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

it's necessary to count "t1t", "t2t", "t3t",... In fact, a number is assiocated with each string => t1t44 is different of t1s44 or t2t44

I have alternatively a number associated to "t1t", "t2t", ... "t3s".

And I want to verify in each suite (writing in a file, separate with "|") how much there are substring with the current number (ex:"t1t34").

Qui ose gagneWho Dares Win[left]CyberExploit[/left]

Link to comment
Share on other sites

then you can use something simular with this

#include <String.au3>
#include <array.au3>
$st = "t1t4t2t89t3t27t1s23t2s91t3s46|t1t22t2t38t3t217t1s52t2s11t3s60|t1t121t2t194t3t44t1s73t2s158t3s84|"
$aArray1 = _StringBetween($st, 't1t', 't')
_ArrayDisplay($aArray1, 'Default Search')
$aArray1 = _StringBetween($st, 't2t', 't')
_ArrayDisplay($aArray1, 'Default Search')
$aArray1 = _StringBetween($st, 't3t', 't')
_ArrayDisplay($aArray1, 'Default Search')
$aArray1 = _StringBetween($st, 't1s', 't')
_ArrayDisplay($aArray1, 'Default Search')
$aArray1 = _StringBetween($st, 't2s', 't')
_ArrayDisplay($aArray1, 'Default Search')
$aArray1 = _StringBetween($st, 't3s', '|')
_ArrayDisplay($aArray1, 'Default Search')

and to combinate it with _ArrayUnique and with _ArraySearch [$iStart] to change position for new search from the place where lastone ended until returned @error

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

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