Jump to content

find in text file how return line?


faustf
 Share

Recommended Posts

hy  guys ,

suppose if i have a simple text  , and inside them i try to  find a letter  i  use stringinstr , but  stringinstr , return me the position  ,  how is possible  know  a line  inside a a tet file ??

i write somthing  but not work

#include <AutoItConstants.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <Date.au3>
#include <EditConstants.au3>
#include <Excel.au3>
#include <File.au3>
#include <FTPEx.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiComboBoxEx.au3>
#include <GuiStatusBar.au3>
#include <GuiListView.au3>
#include <GuiToolbar.au3>
#include <GUIImageList.au3>
#include <GuiEdit.au3>
#include <GDIPlus.au3>
#include <GuiMenu.au3>
#include <GuiScrollBars.au3>
#include <GuiTreeView.au3>
#include <IE.au3>
#include <InetConstants.au3>
#include <Misc.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <ToolbarConstants.au3>
#include <String.au3>
#include <WindowsConstants.au3>
#include <WinAPIRes.au3>
#include <WinAPIShellEx.au3>
#include <WinAPIFiles.au3>
#include <WinAPI.au3>

Local $a="!22"
Local $b="!23"

;Local $path=@ScriptDir&"\sku.txt"
Local $path=@ScriptDir&"\sku2.txt"
Local $testo = FileRead($path)


Local $aArray = StringRegExp($testo, '(?i)<SKU>(.*?)</SKU>', $STR_REGEXPARRAYGLOBALMATCH)
_ArrayDisplay($aArray)

MsgBox(0,'',StringInStr($testo,$a))

this is a tex for  exaple

'<SKU>!22</SKU>' & _
12.00
2.00
Taglia
32

'<SKU>!22!23</SKU>' & _
Taglia coppa
A

'<SKU>!23</SKU>' & _
11.00
1.00
Taglia
34

'<SKU>!22!23</SKU>' & _
Taglia coppa
A

'<SKU>!23</SKU>' & _
Taglia coppa
AA

 

Link to comment
Share on other sites

Something like this here?

#include <Array.au3>
$sText = "'<SKU>!22</SKU>' & _" & @CRLF & _
"12.00" & @CRLF & _
"2.00" & @CRLF & _
"Taglia" & @CRLF & _
"32" & @CRLF & @CRLF & _
"'<SKU>!22!23</SKU>' & _" & @CRLF & _
"Taglia coppa" & @CRLF & _
"A" & @CRLF & @CRLF & _
"'<SKU>!23</SKU>' & _" & @CRLF & _
"11.00" & @CRLF & _
"1.00" & @CRLF & _
"Taglia" & @CRLF & _
"34" & @CRLF & @CRLF & _
"'<SKU>!22!23</SKU>' & _" & @CRLF & _
"Taglia coppa" & @CRLF & _
"A" & @CRLF & @CRLF & _
"'<SKU>!23</SKU>' & _" & @CRLF & _
"Taglia coppa" & @CRLF & _
"AA"

$aSplitted = StringSplit(StringReplace($sText, Chr(10), ""), Chr(13), 2)
$iLinenumber = _ArraySearch($aSplitted, "34")
If $iLinenumber > -1 Then $iLinenumber += 1
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iLinenumber = ' & $iLinenumber & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

 

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

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