Jump to content

Recommended Posts

Posted

I am opening a file and reading it, and I get this line from the file I am reading.:

^*^6fairplay ^Nchris ^&14:32:08 ^<demobase.eu

What I need is the charactor after the ^ only. (so the 6, N, &, < ) I don't want any other part of the string.

I've tried to split up this string but it is not really working. Are there any other methods to get the charactors after the ^

Posted (edited)

It looks like you missed one in your expected results but we can fix that.

$sStr = "^*^6fairplay ^Nchris ^&14:32:08 ^<demobase.eu"
$aMatch = StringRegExp($sStr, "\^(.)", 3);; return a 0 based array of matching characters

If really dont want the * AND if that * is always in the same place change the second line to

$aMatch = StringRegExp($sStr, "\^(.)", 3, 2)
Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted (edited)

Thanks for all of the help but I'm having problems :/

This is the error I got when I tried to run my program.

Error: Subscript used with non-Array variable.

Func getColors()

FileGetTime("demo/MP/qconsole.log")
 If Not @error Then
 FileOpen("demo/MP/qconsole.log", 0)
 $line2 = FileReadLine($file, -1)
 $fairplayline = StringInStr($line2, "fairplay", 2)
 $fairplayline = ($fairplayline - 2)
 If $fairplayline > 1 Then
     If $fpcolor = stringmid($line2,$fairplayline,1) Then
    for $i = 0 to stringlen($line2)
    If  $fpcolor = "^" Then
        $fpcolor = stringmid($line2, ($fairplayline + 1),1)
    EndIf
Next
EndIf
    EndIf
EndIf
bind()
EndFunc

Little Help? :idea:

Edited by Mumms
Posted

Your example doesn't contain any subscripts, so I guess the error is in a different part of the script. Best check the error line number.

My advise is to use the StringRegExp Geosoft gave you btw. It's less code, faster execution and with probably more reliable.

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
  • Recently Browsing   0 members

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