iahngy Posted August 8, 2013 Posted August 8, 2013 (edited) #include <array.au3> $l = "AutoIt_is_a_star" $xl = StringRegExpReplace($l, '.*(is|are).*', '$1.txt') ConsoleWrite($xl) Exit Hi, for the example above, how can i edit the pattern so it only print .txt if there is not any found from the pattern...it just printed the whole line out $l if there is not any is/are found... Edited August 8, 2013 by iahngy
Malkey Posted August 8, 2013 Posted August 8, 2013 I believe the "If...Then...Else" method is the way to go. #include <Misc.au3> Local $l = "AutoIt_i_a_star" ;Local $xl = StringRegExp($l, '(is|are)') ? StringRegExpReplace($l, '.*(is|are).*', '$1.txt') : '.txt' ; For AutoIt Beta version (3.3.9.13) ;Or Local $xl = _Iif(StringRegExp($l, '(is|are)'), StringRegExpReplace($l, '.*(is|are).*', '$1.txt'), '.txt') ; _Iif form Misc.au3 include file. ;Or use If...Then...Else...EndIf ConsoleWrite($xl & @LF)
iahngy Posted August 9, 2013 Author Posted August 9, 2013 (edited) Thank you Malkey. How do i use the newer version of AutoIt into the current editor ...it doesnt compile with the format , StringRegExp($l, '(is|are)') ? StringRegExpReplace($l, '.*(is|are).*', '$1.txt') : '.txt' Edited August 9, 2013 by iahngy
Malkey Posted August 9, 2013 Posted August 9, 2013 The latest beta version is http://www.autoitscript.com/autoit3/files/beta/autoit/autoit-v3.3.9.15-beta-setup.exe With "AutoIt Script Editor.(Customised version of SciTE with lots of additional coding tools for AutoIt)" installed, when "autoit-v3.3.9.15-beta-setup.exe" is installed a "Beta Run", a "Beta Compile", and a "Beta Help" is automatically added to the "Tools" menu of SciTE. So running or compiling the latest release version installed or the latest beta version installed is done by picking the appropriate menu item under SciTE's Tools menu. The conditional operators "... ? ... : ..." only works on the later beta versions and will not compile on the latest AutoIt release version 3.3.8.1. Of course, if you want to see the results of the compiled script, you will need to replace the ConsoleWrite() with a MsgBox() function.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now