Jump to content

StringRegExp and @CRLF or newline


Recommended Posts

this doesn't work when the file has a @CRLF (or "newline")... I think it has something to do with the (.*?) part... any help appreciated!! (p.s. It works how I need it when there's no newlines...)

$szFileName = "testWebScript.txt"
$hFile = FileOpen($szFileName, 0)
Local $s_TotFile = FileRead($hFile, FileGetSize($szFileName))
FileClose($hFile)
$nOffset = 1
While 1
    $array2 = StringRegExp($s_TotFile, '">(.*?)<CH', 1, $nOffset)
    $array = StringRegExp($s_TotFile, '<CHnewtab="(.*?)">', 1, $nOffset)
    If @error = 0 Then
        $nOffset = @extended
    Else
        ExitLoop
    EndIf
    for $i = 0 to UBound($array) - 1
        $tab = "Tab"&$i
        $tab = GUICtrlCreateTabitem($array[$i])
        $edit = "Edit"&$i
        $edit = GUICtrlCreateEdit($array2[$i], $indentX, $indentY, $GUIsize-65, $GUIsize-90)
    Next
WEnd

file being regexed:

<CHnewtab="comments">Content One<CHnewtab="head">Content 2<CHnewtab="body">Content 3three<CHendfile>
Edited by Leoj
Link to comment
Share on other sites

this doesn't work when the file has a @CRLF (or "newline")... I think it has something to do with the (.*?) part... any help appreciated!! (p.s. It works how I need it when there's no newlines...)

$szFileName = "testWebScript.txt"
$hFile = FileOpen($szFileName, 0)
Local $s_TotFile = FileRead($hFile, FileGetSize($szFileName))
FileClose($hFile)
$nOffset = 1
While 1
    $array2 = StringRegExp($s_TotFile, '">(.*?)<CH', 1, $nOffset)
    $array = StringRegExp($s_TotFile, '<CHnewtab="(.*?)">', 1, $nOffset)
    If @error = 0 Then
        $nOffset = @extended
    Else
        ExitLoop
    EndIf
    for $i = 0 to UBound($array) - 1
        $tab = "Tab"&$i
        $tab = GUICtrlCreateTabitem($array[$i])
        $edit = "Edit"&$i
        $edit = GUICtrlCreateEdit($array2[$i], $indentX, $indentY, $GUIsize-65, $GUIsize-90)
    Next
WEnd

file being regexed:

<CHnewtab="comments">Content One<CHnewtab="head">Content 2<CHnewtab="body">Content 3three<CHendfile>
Seems to work ok when I create a file with repeated lines as your example seperated by @CRLF.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • Moderators

Place (?s) at the beginning of your pattern and see if that helps.

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

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