Jump to content

Make a metasymbol condition to make operations over the text file line


Tosyk
 Share

Recommended Posts

Hi,

Please help me to change metasymbol line. Right now I have this condition code:

If StringInStr($_sName, 'TEXT ') Then
    $_sName = StringRegExpReplace($_sName, '(^.*)\TEXT (.*)$', '$2')
    $_sName = StringRegExpReplace($_sName, '(^.*)\ (.*)$', '$1')
    If Not CheckIsSave_($_sName) Then

It work fine with this text file and finds each line which start from 'TEXT':

Material B7E671143D244B
====================================
TEXT 2F3139D816C34D 1
TEXT B6A968EF2505A2 1
TEXT 35206697A04F91 1
TEXT EB485AF490D83D 1
TEXT 0DAB42294BD9B3 1
TEXT 3D6525BEE360E1 0

Material D6906B886B06E3
====================================
TEXT 0CCECCCCFB62AE 1
TEXT 1E14CB29AB43F0 1
TEXT FB7F0DCE9B5950 1

But I have a new text file now the lines of which now are start with 0:, 1: and so on:

sm_0
---------------
0: dummy_gray
1: c_com_socksa_mt
2: c_com_socksa_tn
3: dummy_white
4: default_z
5: dummy_nmap
6: ---
7: ---

sm_1
---------------
0: c_com_prisoner_shoes_di
1: c_com_prisoner_shoes_mt
2: c_com_prisoner_shoes_tn
3: dummy_white
4: default_z
5: c_com_leatherb_rt
6: ---
7: ---

how to change (or add) the condition code above to work with new text file?

I'm trying to change this script: http://autoit-script.ru/threads/poisk-fajlov-rekursivno-po-dannomu-spisku.26970/post-148646

 

Link to comment
Share on other sites

$_sName = 'TEXT 2F3139D816C34D 1'
If StringInStr($_sName, 'TEXT ', 1) Then
    $_sName = StringRegExpReplace($_sName, '(^.*)\TEXT (.*)$', '$2')
    $_sName = StringRegExpReplace($_sName, '(^.*)\ (.*)$', '$1')
    ConsoleWrite($_sName & @CRLF)
EndIf

$_sName = '2: c_com_socksa_tn'
If StringInStr($_sName, ': ', 1) Then
    $_sName = StringRegExpReplace($_sName, '(^.*)\d: (.*)$', '$2')
    ConsoleWrite($_sName & @CRLF)
EndIf

 

Link to comment
Share on other sites

Another example.

#cs ; --------- Test Data ----------
Material B7E671143D244B
====================================
TEXT 2F3139D816C34D 1
TEXT B6A968EF2505A2 1
TEXT 35206697A04F91 1
TEXT EB485AF490D83D 1
TEXT 0DAB42294BD9B3 1
TEXT 3D6525BEE360E1 0

Material D6906B886B06E3
====================================
TEXT 0CCECCCCFB62AE 1
TEXT 1E14CB29AB43F0 1
TEXT FB7F0DCE9B5950 1

But I have a new text file now the lines of which now are start with 0:, 1: and so on:

sm_0
---------------
0: dummy_gray
1: c_com_socksa_mt
2: c_com_socksa_tn
3: dummy_white
4: default_z
5: dummy_nmap
6: ---
7: ---

sm_1
---------------
0: c_com_prisoner_shoes_di
1: c_com_prisoner_shoes_mt
2: c_com_prisoner_shoes_tn
3: dummy_white
4: default_z
5: c_com_leatherb_rt
6: ---
7: ---
#ce ; ----- End of Test Data ----------

#include <Array.au3>

$_aName = StringRegExpReplace(FileRead(@ScriptFullPath), '(?is)(^.*#cs[^\R]*\R)|(\R#ce.*$)', "") ; Extract test data from script.
;ConsoleWrite( $_aName& @CRLF)

$_aName = StringRegExp($_aName, '(?m)^(?:TEXT|\d+:\h)(.*$)', 3) ; Extract required text from test data. (Lines starting with "TEXT ", or, digits with a ": ".

ConsoleWrite(_ArrayToString($_aName, @CRLF) & @CRLF)
_ArrayDisplay($_aName)

 

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