Jump to content
tezhihi

StringRegExReplace in File.

Recommended Posts

tezhihi

I have a file (see attached file) with a string all line and this problem on here is I want to separate all $00:, $03:, $10:, $20:, $25:, $30:, $40:, $45:, $110:, $115:, $120: and $T. It's mean that each $ with value start a new line ( a new paragraph). I tried with Regular Expression in notepad++ ex:

Find ($00:, $01:, $03: and so on) with regex (\$)([0-9]+): and replace is \r\n\1\2 (I think \r\n is @CRLF (not sure :() )

Find $T with regex (\$T)(.*?)(\$T) and replace is \1\2\r\n\3

When I try these regex to replace in notepad on StringRegexReplace the results is incorrect :(. I have read some example simple about regex. Please advise me how to do that with some example on autoit :(. The result will be in attached photo. Thanks 

ahihi.txt

result.png

Share this post


Link to post
Share on other sites
tezhihi

aaaa

Edited by tezhihi

Share this post


Link to post
Share on other sites
JLogan3o13

@tezhihi please wait 24 hours before bumping your thread. All of our forum members assist as they are able, and not all are in the same time zone; the person best able to assist you may not be online right now.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
tezhihi
11 minutes ago, JLogan3o13 said:

@tezhihi please wait 24 hours before bumping your thread. All of our forum members assist as they are able, and not all are in the same time zone; the person best able to assist you may not be online right now.

Sorry about that. Thanks you

Share this post


Link to post
Share on other sites
mikell

What about this ?

$txt = FileRead("ahihi.txt")

$output = StringRegExpReplace($txt, '(?<!^|:)(?=\$(?:00|03|10|20|25|30|40|45|110|115|120|T))', @crlf)
FileWrite("output.txt", $output)

Meaning :
Search positions (not preceded by start of text or a colon) and (followed by $00, $03 and so on)
and at these positions insert a crlf
:)

Edited by mikell
  • Like 1

Share this post


Link to post
Share on other sites
tezhihi
10 hours ago, mikell said:

What about this ?

$txt = FileRead("ahihi.txt")

$output = StringRegExpReplace($txt, '(?<!^|:)(?=\$(?:00|03|10|20|25|30|40|45|110|115|120|T))', @crlf)
FileWrite("output.txt", $output)

Meaning :
Search positions (not preceded by start of text or a colon) and (followed by $00, $03 and so on)
and at these positions insert a crlf
:)

Awesome. I have a more question.

I want to link between 2 $ with text below:

$F$%$?$%- - - - - - - - - - - - - - - - - -Footnotes- - - - - - - - - - - - - - - - - -
$Tn1 Subsequent to oral argument by letter, dated December 16, 2005 Scrushy's attorney submitted to the Court a "Memo" dated 7/19/04 and apparently prepared by a Pamela Anderson. This "Memo" contains unverified, unsworn rank hearsay and the Court has not considered the contents of this document in reaching its decision.$%$?$%- - - - - - - - - - - - - - - - -End
 Footnotes- - - - - - - - - - - - - - - - -$E$=P1298*3

$F with $Tn1 and Delete $%$?$%- - - - - - - - - - - - - - - - -End Footnotes- - - - - - - - - - - - - - - - -             and the result should be 

$F$Tn1 Subsequent to oral argument by letter, dated December 16, 2005 Scrushy's attorney submitted to the Court a "Memo" dated 7/19/04 and apparently prepared by a Pamela Anderson. This "Memo" contains unverified, unsworn rank hearsay and the Court has not considered the contents of this document in reaching its decision.$E$=P1298*3

Kindly check and advise me. Thanks you

Edited by tezhihi

Share this post


Link to post
Share on other sites
mikell

Here it is

$str = '$F$%$?$%- - - - - - - - - - - - - - - - - -Footnotes- - - - - - - - - - - - - - - - - -' & @crlf & _ 
'$Tn1 Subsequent to oral argument by letter, dated December 16, 2005 Scrushy''s attorney submitted to the Court a "Memo" dated 7/19/04 and apparently prepared by a Pamela Anderson. This "Memo" contains unverified, unsworn rank hearsay and the Court has not considered the contents of this document in reaching its decision.$%$?$%- - - - - - - - - - - - - - - - -End' & @crlf & _ 
' Footnotes- - - - - - - - - - - - - - - - -$E$=P1298*3'

;msgbox(0,"", $str)

$str2 = StringRegExpReplace($str, '\$%\$\?\$%[^\$]+', "")
msgbox(0,"", $str2)

This removes any non-$ char from "$%$?$%" up to the next $ char
Please note that you have to first manage the single quote(s) included in the string
:)

  • Like 1

Share this post


Link to post
Share on other sites
tezhihi
58 minutes ago, mikell said:

Here it is

$str = '$F$%$?$%- - - - - - - - - - - - - - - - - -Footnotes- - - - - - - - - - - - - - - - - -' & @crlf & _ 
'$Tn1 Subsequent to oral argument by letter, dated December 16, 2005 Scrushy''s attorney submitted to the Court a "Memo" dated 7/19/04 and apparently prepared by a Pamela Anderson. This "Memo" contains unverified, unsworn rank hearsay and the Court has not considered the contents of this document in reaching its decision.$%$?$%- - - - - - - - - - - - - - - - -End' & @crlf & _ 
' Footnotes- - - - - - - - - - - - - - - - -$E$=P1298*3'

;msgbox(0,"", $str)

$str2 = StringRegExpReplace($str, '\$%\$\?\$%[^\$]+', "")
msgbox(0,"", $str2)

This removes any non-$ char from "$%$?$%" up to the next $ char
Please note that you have to first manage the single quote(s) included in the string
:)

Can I search the string "$=<$=T3*1 $=L00180000845001096*001106" on regex

1.  "\$=<\$=T([0-9]+)\*([0-9]+)\s\$=L.+?\*(([0-9]+){6})"

or

2. "\$=<\$=T[^\$]+\$=L[^\$]+"

I want to remove it :)

Edited by tezhihi

Share this post


Link to post
Share on other sites
mikell

I saw that this string exists (with various flavours) several times in the file. To remove them all you might use a more selective expression to limit the risk of errors

StringRegExpReplace($str, '\$=<\$=T3\*1\s+\$=L\d+\*\d+', "")

:)

  • Like 1

Share this post


Link to post
Share on other sites
tezhihi
28 minutes ago, mikell said:

I saw that this string exists (with various flavours) several times in the file. To remove them all you might use a more selective expression to limit the risk of errors

StringRegExpReplace($str, '\$=<\$=T3\*1\s+\$=L\d+\*\d+', "")

:)

Oh thanks youuuu so much.

He received the following bonuses for the years shown:$M05,06,13,13,13,33$GFOR$JANNUAL$JTARGET$JTOTAL$JDESCRIPTION$GYEAR$JBONUS$JBONUS$JINCENTIVE$G$J$J$JBONUS$D$Q2002$B$ 10,000,000$B$ 1,200,000$Y$ 11,200,000$BAnnual Bonus in and for 2002$Q$B$B$Y$Balso paid in 2002. Net income$Q$B$B$Y$Bwas negative $ (467 million.)$Q$B$B$Y$BApproved by the Compensation$Q$B$B$Y$BCommittee on April 29, 2002.$Q$Q2001$B$ 6,500,000$B$ 2,400,000$Y$ 8,900,000$BNet income for 2001 was negative$Q$B$B$Y$B$ (191 million). Bonuses$Q$B$B$Y$Breported in the proxy filed$Q$B$B$Y$BApril 12, 2002.$Q$Q2000$BNone.$B$ 2,154,849$Y$ 2,154,849$BNet income for 2000 was a$Q$B$B$Y$Bnegative $ (364 million).$Q$Q1999$BNone.$B$ 134,031$Y$ 134, 031$BFinancials fraudulent but no$Q$B$B$Y$Baudited restatement.$Q$Q1998$BNone.$B$ 1,577,829$Y$ 1,577,829$BFinancials fraudulent but no$Q$B$B$Y$Baudited restatement.$Q$Q1997$B$ 10,000,000$B$ 2,400,000$Y$ 12,400,000$BAnnual Bonus was reported in$Q$B$B$Y$Bproxy dated April 17, 1998, as$Q$B$B$Y$Bbeing for and earned in 1997.$Q$Q1996$B$ 8,000,000$B$ 2,400,000$Y$ 10,400,000$BAnnual Bonus was reported in$Q$B$B$Y$Bproxy dated April 9, 1997, as$Q$B$B$Y$Bbeing for, and earned in, 1996.$Q$QTotal$B$ 34,500,000$B$ 12,266,709$Y$ 46,766,709$BBefore Prejudgment Interest$X$=P1298*7 $T5. In each annual proxy on Form 14A, HealthSouth disclosed the following criteria for Incentive Bonuses paid to its executives:$=S$%$?$%Incentive Compensation: In addition to base salary, the $(Compensation$) Committee recommends to the Board of Directors cash incentive compensation for HealthSouth's executives, based on each executive's success in meeting qualitative and quantitative performance goals on an annual basis.

Are I correct if i use these code below:

StringRegExpReplace(FileRead("ahihi.txt"), '(?=\$(?:M))', @crlf)     ;For create a new paragraph with $M (ex: $M05,06,13,13,13,33$GFOR$JA ......)
StringRegExpReplace(FileRead("ahihi.txt"), '\$=P\d+\*\d+', '')       ;For remove all $=P1298*x
StringRegExpReplace(FileRead("ahihi.txt"), '\$=>', '')               ;For remove all $=>

 

Share this post


Link to post
Share on other sites
mikell

Yes you are. They will all work correctly, some remarks yet :

The first one will insert a crlf just before any $M encountered, so it could be done a little simpler

StringRegExpReplace(FileRead("ahihi.txt"), '(?=\$M)', @crlf)

If the second one is made to remove all "$=P1298*x" precisely then it could be done more selective - which is always a good idea when using regex

StringRegExpReplace(FileRead("ahihi.txt"), '\$=P1298\*\d+', '')

Nothing to say about the third  :)

  • Like 1

Share this post


Link to post
Share on other sites
tezhihi
On 5/6/2017 at 1:49 AM, mikell said:

Yes you are. They will all work correctly, some remarks yet :

The first one will insert a crlf just before any $M encountered, so it could be done a little simpler

StringRegExpReplace(FileRead("ahihi.txt"), '(?=\$M)', @crlf)

If the second one is made to remove all "$=P1298*x" precisely then it could be done more selective - which is always a good idea when using regex

StringRegExpReplace(FileRead("ahihi.txt"), '\$=P1298\*\d+', '')

Nothing to say about the third  :)

Case 1:

After I used the code below:

#include <File.au3>
$a = FileRead(@ScriptDir & '\ahihi.txt')
$b = StringRegExpReplace($a, '(\$%\$\?\$%)(?=\$=B)', '\1' & @CRLF & '\2')
$c = StringRegExpReplace($b, '\$%\$\?\$%[^\$]+', "")
$d = StringRegExpReplace($c, '(?<!^|:)(?=\$(?:00|01|03|10|20|25|30|40|45|110|115|120|T|F|200|220))', @crlf)
$e = StringRegExpReplace($d, '(?=\$M)', @crlf)
$f = StringRegExpReplace($e, '(\$F)(\R)(\$Tn)', '\1\3')
$g = StringRegExpReplace($f, '\$=<\$=T\d+\*\d+\s+\$=L\d+\*\d+', '')
$h = StringRegExpReplace($g, '\$=P\d+\*\d+', '')
$i = StringRegExpReplace($h, '(\$E)\$%\$\?\$%(\$=B)', '')
$j = StringRegExpReplace($i, '\$I\s+\$U', '$I$U')
$k = StringRegExpReplace($j, '\$=>', '')
FileWrite("output.txt", $k)

Output file has been appeared problem (please see in the red box on image ____ All $T with symbol ' : ' ). I think this problem will be solve when i use code below:

Untitled-2.png

StringRegExpReplace(FileRead("ahihi.txt"), '(\:)(\$T)(\$=B)', '\1' & @CRLF & '\2\3')

StringRegExpReplace(FileRead("ahihi.txt"), '([a-z]+)(\:)(\$T)', '\1\2' & @CRLF & '\3')

Otherwise, please advise me.

 

Case 2:

$str = '$T$F$%$?$%- - - - - - - - - - - - - - - - - -Footnotes- - - - - - - - - - - - - - - - - - n1 Liggett has been rewarded handsomely in the settlement with the Attorneys General for its historic cooperation. $%$?$%- - - - - - - - - - - - - - - - -End Footnotes- - - - - - - - - - - - - - - - -$E'   ;This is one line not include @CRLF

$str2 = StringRegExpReplace($str, '\$%\$\?\$%[^\$]+', "")

The results is ' $F$E ' not include text data inside.

I will resolve it as code below:

$str = '$T$F$%$?$%- - - - - - - - - - - - - - - - - -Footnotes- - - - - - - - - - - - - - - - - - n1 Liggett has been rewarded handsomely in the settlement with the Attorneys General for its historic cooperation. $%$?$%- - - - - - - - - - - - - - - - -End Footnotes- - - - - - - - - - - - - - - - -$E'

$str2 = StringRegExpReplace($str, '(\$%\$\?\$%[^\$]+)(n\d+)', '\2')

Otherwise, please advise me.

Edited by tezhihi

Share this post


Link to post
Share on other sites
mikell

The case 2 could be done like this

StringRegExpReplace($str, '\$%\$\?\$%.+?(?=n\d|\$)', "")

For case 1 this is possible

StringRegExpReplace($str, '(?<=:)(?=\$T\$=B)', @CRLF)

But it becomes a little difficult for me as I don't know exactly which "$x" things you want to keep and which ones you want to remove :sweating:
Maybe all this could be done simpler depending on what should be the final result after complete treatment of the initial file

  • Like 1

Share this post


Link to post
Share on other sites
mikell

@tezhihi

6 hours ago, mikell said:

Maybe all this could be done simpler depending on what should be the final result

For instance could this be correct ?

$s = FileRead(@ScriptDir & '\ahihi.txt')
$s = StringRegExpReplace($s, '\R|(\$F)?\$%\$\?\$%[^\$]*', "")  ; footnotes
$s = StringRegExpReplace($s, '(?<!^|:)(?=\$(?|00|01|03|10|20|25|30|40|45|110|115|120|200|220|T|M))', @crlf)
$s = StringRegExpReplace($s, '(\$(?|[DXOENUI\?%]|=[BRIS<>]|=[PLT]\d+\*\d+))+', "")
$s = StringRegExpReplace($s, '(\$[MBJGQY])+', " ")

$s = StringRegExpReplace($s, '\$T', "")
FileWrite("output.txt", $s)

 

  • Like 1

Share this post


Link to post
Share on other sites
tezhihi
13 hours ago, mikell said:

@tezhihi

For instance could this be correct ?

$s = FileRead(@ScriptDir & '\ahihi.txt')
$s = StringRegExpReplace($s, '\R|(\$F)?\$%\$\?\$%[^\$]*', "")  ; use this code will be deleted some text data
$s = StringRegExpReplace($s, '(?<!^|:)(?=\$(?|00|01|03|10|20|25|30|40|45|110|115|120|200|220|T|M))', @crlf) 
$s = StringRegExpReplace($s, '(\$(?|[DXOENUI\?%]|=[BRIS<>]|=[PLT]\d+\*\d+))+', "") ; use this code will delete all $ with value. Each $ corresponding with font or indent at start paragraph and some others data.
$s = StringRegExpReplace($s, '(\$[MBJGQY])+', " ") ; just make a new paragraph start with $M and end with $X. I will modify after replace all done

$s = StringRegExpReplace($s, '\$T', "") ; $T is segment required in text file = indent at start paragraph
FileWrite("output.txt", $s)

 

@mikell oh no :( the result of output will be same with the result from output.txt of my code :(. Please see remark on your code.

 

I will send you the list of data need to delete in text file. Please see  new 2.txt     

I have multiple file like that for modify. I need to make a tool for un string all of them. Please check the correctness of the code below

#include <File.au3>
$a = FileRead(@ScriptDir & '\ahihi.txt')
$a = StringRegExpReplace($a, '(\$%\$\?\$%)(?=\$=B)', '\1' & @CRLF & '\2')
$a = StringRegExpReplace($a, '(\$%\$\?\$%[^\$]+Footnotes[^\$]+)(n\d+)', '\2')
$a = StringRegExpReplace($a, '\$%\$\?\$%[^\$]+Footnotes[^\$]+', '')
$a = StringRegExpReplace($a, '(\$%\$\?\$%[^\$]+)(\$E)', '\2')
$a = StringRegExpReplace($a, '(?<!^|:)(?=\$(?:00|01|03|10|20|25|30|40|45|110|115|120|T|F|200|220))', @CRLF)
$a = StringRegExpReplace($a, '(?=\$M)', @CRLF)
$a = StringRegExpReplace($a, '(?=\$=S)', @CRLF)
$a = StringRegExpReplace($a, '(?=\$%\$\?\$%)', @CRLF)
$a = StringRegExpReplace($a, '(\$F)(\R)(\$Tn)', '\1\3')
$a = StringRegExpReplace($a, '(\$T)(\R)(\$F)', '\3\1')
$a = StringRegExpReplace($a, '(\s)(\$E)', '\2')
$a = StringRegExpReplace($a, '\$=<\$=T\d+\*\d+\s+\$=L\d+\*\d+', '')
$a = StringRegExpReplace($a, '\$=<\$=T\d+\*[^\$]+\$=L\d+\*\d+', '')
$a = StringRegExpReplace($a, '\$=P\d+\*\d+', '')
$a = StringRegExpReplace($a, '(\$E)\$%\$\?\$%(\$=B)', '')
$a = StringRegExpReplace($a, '\$I\s+\$U', '$I$U')
$a = StringRegExpReplace($a, '\$=>', '')
$a = StringRegExpReplace($a, '(?<=:)(?=\$T\$=B)', @CRLF)
$a = StringRegExpReplace($a, '([A-Z][a-z].+\:)(\$T)', '\1' & @CRLF & '\2')
$a = StringRegExpReplace($a, '(\$E)(\$=B)', '\1' & @CRLF & '\2')
$a = StringRegExpReplace($a, '(\$00:)(.+)', '\1')
$a = StringRegExpReplace($a, '\$03:.+\R', '')
$a = StringRegExpReplace($a, '\$30:.+\R', '')
$a = StringRegExpReplace($a, '(\$200:)(.+)', '\1')
$a = StringRegExpReplace($a, '(\$%\$\?\$%)(\R)(\$=B)', '\1\3')
$a = StringRegExpReplace($a, '(\$120:)(\R)(\$T)', '\1\3')
$a = StringRegExpReplace($a, '(\$120:)(\R)(\$%\$\?\$%)', '\1\3')
$a = StringRegExpReplace($a, '(\$120:\$%\$\?\$%)(\R)(\$=B)', '\1\3')
$a = StringRegExpReplace($a, '(\$=S)(\R)(\$%\$\?\$%)', '\1\3')
$a = StringRegExpReplace($a, '(\$%\$\?\$%)(\s)', '\1')
$a = StringRegExpReplace($a, '(\$01:.+)(\R\$%\$\?\$%.+)', '\1')
$a = StringRegExpReplace($a, '\$(?|=L\d+\*\d+)', '')
FileWrite("output.txt", $a)

 

Edited by tezhihi

Share this post


Link to post
Share on other sites
tezhihi

@mikell follow up :( need your help

Share this post


Link to post
Share on other sites
mikell

I do follow... my previous post was just a little play - because obviously you need a final file with a very particular formatting
I tried to guess the signification of the various $x (i.e. $F = Footnotes, and so on) but I quickly gave up :sweating:
Actually you have a bunch of SRER and some of them are redundant , but they are not so bad and they do the job
To help you I need precise infos... the best would be to build manually a final file, so when comparing I can know exactly what you want :)

 

  • Like 1

Share this post


Link to post
Share on other sites
tezhihi
1 hour ago, mikell said:

I do follow... my previous post was just a little play - because obviously you need a final file with a very particular formatting
I tried to guess the signification of the various $x (i.e. $F = Footnotes, and so on) but I quickly gave up :sweating:
Actually you have a bunch of SRER and some of them are redundant , but they are not so bad and they do the job
To help you I need precise infos... the best would be to build manually a final file, so when comparing I can know exactly what you want :)

 

@mikell Ok i will send for you the completed file for compare when im in office. This file completed with the best person. I will send you the full information for processing with regex with all take note of them. :) 

 

 

Share this post


Link to post
Share on other sites
mikell

Nice. The more I have infos, the more I can make suggestions  :)

  • Like 1

Share this post


Link to post
Share on other sites
tezhihi
6 hours ago, mikell said:

Nice. The more I have infos, the more I can make suggestions  :)

Hi @mikell can you check the For Mikell.xls file with remark and check EXAMPLE.TXT (This is Results of ahihi.txt) and help me. If you need more information please advise me.

Oh I have a new one file for you to try processing: New For Process.txt

Edited by tezhihi

Share this post


Link to post
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

  • Similar Content

    • milkmoron
      By milkmoron
      I am trying to search in a web browser dates XX/XX/XXXX that are also links. I want to click them after and remove them from the array. This is all I have so far. Nothing shows up. What am I doing wrong?
      ControlFocus ("Customer Center", "", "")
      Local $aArray = StringRegExp('(..)/(..)/(....)', '(..)/(..)/(....)', $STR_REGEXPARRAYFULLMATCH)
      For $i = 0 To UBound($aArray) - 1
          MsgBox($MB_SYSTEMMODAL, "RegExp Test with Option 2 - " & $i, $aArray[$i])
      Next
       
    • WoodGrain
      By WoodGrain
      Hi All,
      I'd like to replace 'COMMA' with ',' for example:
      $myString = "COMMA" StringRegExpReplace($myString, 'COMMA', ',') Now I've tried escaping the ',' in various ways unsuccessfully, such as:
      '[,]'
      "[,]"
      '\,'
      [,] seems to work in the pattern, I just can't figure out how to use it in the replace, and it seems everyone online is only interested in removing/replacing commas lol.
      I also tried creating and using a variable as the replacement but also didn't work:
      $myComma = "," $myString = "COMMA" StringRegExpReplace($myString, 'COMMA', $myComma) I'm sure it's super simple if someone could point me in the right direction - thanks.
    • kneze
      By kneze
      hi
      i use from Command Line net user /Domain UserID >> C:\temp\sample.txt to request informations about specific Domain User. Now i wil get Password last set, Password expires, password changeable and all Groups from Global Group Membership of this User to display in a MsgBox. With FUNC _readGroups i can check which position is group date of last password set but i don't know how to get needed informations as i wrote at the beginning.
      Thanks in advance for any hint how can i solve it.
      #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.3 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <File.au3> $FilePath=@ScriptDir &"\sample.txt" $StringToSearch="Password last set" $CaseSense=0 $Lines=_FileCountLines($FilePath) $hFile=FileOpen($FilePath,0) $LinesCount=_FileCountLines($FilePath) For $i=0 To Number($Lines) $Test=FileReadLine($hFile,$i) If StringInStr($Test,$StringToSearch,$CaseSense) Then $foundLine = $i _readGroups($foundLine,$LinesCount,$i) ;MsgBox(0,"","The string " & $StringToSearch & " was found on line " & $i) ;MsgBox(0,"","Lines found: " & $LinesCount) ExitLoop EndIf Next FileClose($hFile) FUNC _readGroups($foundLine,$LinesCount,$i) ;For $j=$foundLine To Number($LinesCount) $lLine=FileReadLine($hFile,$i) ;$split = StringSplit($lLine," ") $split = StringSplit(StringStripWS($lLine,1)," ") For $x = 1 To $split[0] MsgBox(0,$x,$split[$x]) Next ;MsgBox(0,"",$split[15]& " " & $split[16]) ;Next EndFunc  
      sample.txt
    • rcmaehl
      By rcmaehl
      Hi all,
      I still suck at regex as always and I need some help. According to the regex tester I normally use this should be working fine but it doesn't....
      StringRegExp($sString, "\A[1-9]+[0-9]*(\-[1-9]+[0-9]*)?,*\Z") I basically want to match:
      all numbers EXCEPT 0, but including 10, 20, etc with each number separated by a comma and allowing a "-" separated range as a value For example:
      1-5,7,10-12 I've spent a couple hours modifying it but I'm not sure where I've gone wrong. Any help would be appreciated!
    • ISI360
      By ISI360
      Hi!

      I need a little bit help from some RegEx experts please:
      I would make my ISN AutoIt Studio faster when generating the scripttree. And what would be better to do this via regex?
      Problem is i am not really good at this regex stuff. So maybe someone could help me here.
       
      The challange is to get all Global Variables from a script via RegEx in a Array.
      Here is a example script with some tests:
      Global $Var1 = 1234 Local $Local_Var = 1234 $Ignore_me_too = 1234 Global $Var2 = 1234, $var3 = 1242 Global $ahIcons[30], $ahLabels[30] Global Const $Var4 = iniread($inivar1,"jj","jj","") , $var5= iniread($inivar2,"jj","jj","") Global $Var_String = "was" Global $Array_Test[16] = [1,15,16,0,31,15,25,15,25,30,8,30,8,15,1,15] Global Enum $MARGIN_SCRIPT_NUMBER = 0, $MARGIN_SCRIPT_ICON, $MARGIN_SCRIPT_FOLD Global Const $Delim = '\', $Delim1 = '|' Global $hard1 = "a", _ $hard2 = "b", _ $hard3 = "c"  
      The returning array should look like this:
      $Var1 $Var2 $var3 $Var4 $var5 $Var_String $Array_Test $MARGIN_SCRIPT_NUMBER $MARGIN_SCRIPT_ICON $MARGIN_SCRIPT_FOLD $Delim $Delim1 $hard1 $hard2 $hard3  
      I already made some success with a expression i found in the SciTE Jump Tool:  (\$\w+)(?:[\h\[.=+*/^,)\-])?
      This nearly returns the perfect results. But it does not check if it´s a global variable (with the const and enum options) and also returns variables in commands (for example $inivar1)
      I also found this regex: (?im:^(?=Global|Const|Enum|Static)(?:Global)?\h*(?:Const|Enum|Static)?(?:(?<=Enum)\h+Step\h+[+*-]\d+)?\h*)([^\r\n .\=]+)
      This returns also usefull results...but trying to understand this explodes my head

      Maybe someone can help me here?
      Thanks in advance!
×