Search the Community

Showing results for tags 'regex'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Chat
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum
  • AutoIt

Calendars

  • Community Calendar

Found 39 results

  1. 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
  2. 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!
  3. Can anyone tell me why this isn't working?.. #include <array.au3> $regexp = StringRegExp("test 'a b c'", "'([^']|'')*'|\S+", 3) _ArrayDisplay($regexp) trying to split this "test 'a b c' 'some other '' test'' ...'" into: 0: test 1: 'a b c' 2: ... but it gives me: 0: test 1: c
  4. Hi guys, I am pretty bad with regex, and am having some trouble trying to come up with an expression for a certain type of string. Basically I want to be able to tell if a string is of the format: AA#####A Where the A's are any letter from A-Z and the #'s are any digit from 0-9. I've been playing around with a regex tester online for a while but I can't really seem to grasp the concept very well. Could anyone give me any tips? This isn't exactly an AutoIt specific question which is why I didn't post it in General Help & Support.
  5. Hello, i need to validate a string can be different things. I just need a True - False return value, no groups or things like that. It will be always one line at time to be processed by StringRegEx Valid: 13:52|String 02:52 XX|String 13:52~SUN, MON, TUE, WED, THU, FRI, SAT|String 02:52 XX~SUN, MON, FRI|String 22/04/2017 13:52|String 22/04/2017 02:52 YY|String Not Valid 22/04/2017 13:52~Dom|String I need to validate until and inclusively the | after that i don't care The XX and YY value are two $sVariable from my script SUN, MON, TUE, WED, THU, FRI, SAT are fixed value, the can be mixed but always in the same order like SUN SUN, TUE, WED SUN, SAT The time can be 12 or 24 hours, the date is always in the same format DD/MM/YYYY. If there is a date can't be a day after that ( see not valid ) Well i think is all Sorry if i don't provide a working code, regex is too way complex. Thanks
  6. Hello. I need to list only the folders that has a name composed of numbers only. How do I do this? OBS: I just posted the relevant content to the folder. Global $path = "G:\jobs\" For $i = 1 To $aArray[0] Local $search = FileFindFirstFile($path & $aArray[$i] & "\[0-9]" ) I tried with "\*.*" and it returns me the expected result, but the other doesn't.
  7. Hi all, it's been a while since I last used regular expressions and I find myself out of time to experiment with this particular issue, so I throw myself upon your mercy and expertise. I am looking to create a function that will say whether or not a supplied string is a valid UUID or not. Local $sTestF = '4C4C4544-004A-4C10-8054-B7C04F46343' Local $sTestT = '4C4C4544-004A-4C10-8054-B7C04F463432' ConsoleWrite('False = ' & _IsValidUUID($sTestF) & @CRLF) ConsoleWrite('True = ' & _IsValidUUID($sTestT) & @CRLF) Func _IsValidUUID($sUUID) ;[\p{XDigit}]{8}-[\p{XDigit}]{4}-[34][\p{XDigit}]{3}-[89ab][\p{XDigit}]{3}-[\p{XDigit}]{12} ; Test UUID = '4C4C4544-004A-4C10-8054-B7C04F463432' Local $sRegExp = '([:xdigit:]){8}\-([:xdigit:]){4}\-([34])([:xdigit:]){3}\-([89ab])([:xdigit:]){3}\-([:xdigit:]){12}' ConsoleWrite(StringRegExp($sUUID, $sRegExp) & @CRLF) Local $Result = StringRegExp($sUUID, $sRegExp) ConsoleWrite($Result & @CRLF) If @error Then ConsoleWrite('Error: [' & @error & ']' & @CRLF) Return 'False' Else ConsoleWrite('Error2: [' & @error & ']' & @CRLF) Return 'True' EndIf EndFunc In the line under the Function call, you'll see the regex I found to do this from a google search. That was my starting point, and I'm trying to get it to work in Au3 and failing miserably. $sTestF is a known invalid String $sTestT is a known valid String Everything I've tried so far has produced the same results for both. Any help you could provide me is greatly appreciated. Thanks for your time!
  8. Hi, I need help string RegEx to get string from CREATE to GO #include <StringConstants.au3> ;~ Global $fileSQL1 = @ScriptDir & "\fileSQL1.sql" ;~ Global $fileSQL2 = @ScriptDir & "\fileSQL2.sql" Global $tmpSQLfile = @TempDir & "\tmpFile.sql" OnAutoItExitRegister("_OnExit") _SetTMPsql() If Not FileExists($tmpSQLfile) Then OnAutoItExitUnRegister("_OnExit") Exit MsgBox(48, "/!\", "File: " & $tmpSQLfile & @CRLF & " is not Exists!", 3) EndIf Global $ContentSQLfile = FileRead($tmpSQLfile) _Start() Func _Start() Local $aArray, $iOffset = 1, $stringRegExp = '(?i)CREATE(.*?)GO' While 1 $aArray = StringRegExp($ContentSQLfile, $stringRegExp, $STR_REGEXPARRAYMATCH, $iOffset) If @error Then MsgBox(48, "StringRegExp Error " & @error, "+> StringRegExp: " & $stringRegExp & @CRLF & @CRLF & "=> With STRING:" & @CRLF & @CRLF & $ContentSQLfile) ExitLoop EndIf $iOffset = @extended For $i = 0 To UBound($aArray) - 1 MsgBox(0, "RegExp Test with Option 1 - " & $i, $aArray[$i]) Next WEnd EndFunc ;==>_Start Func _SetTMPsql() Local $tmpSQLContent = "" $tmpSQLContent &= "USE [Master]" & @CRLF $tmpSQLContent &= "GO" & @CRLF $tmpSQLContent &= "" & @CRLF $tmpSQLContent &= "CREATE DATABASE [Sales] ON PRIMARY " & @CRLF $tmpSQLContent &= "( NAME = N’Sales’, FILENAME = N’\FSASQLDBSales.mdf’ , " & @CRLF $tmpSQLContent &= " SIZE = 2GB , MAXSIZE = 8GB, FILEGROWTH = 1GB )" & @CRLF $tmpSQLContent &= "LOG ON " & @CRLF $tmpSQLContent &= "( NAME = N’Sales_log’, FILENAME = N’\FSASQLDBSales_log.ldf’ , " & @CRLF $tmpSQLContent &= " SIZE = 1GB , MAXSIZE = 2GB , FILEGROWTH = 10%)" & @CRLF $tmpSQLContent &= "GO" & @CRLF $tmpSQLContent &= "" & @CRLF $tmpSQLContent &= "USE [Sales]" & @CRLF $tmpSQLContent &= "GO" & @CRLF $tmpSQLContent &= "" & @CRLF $tmpSQLContent &= "-- Table Product" & @CRLF $tmpSQLContent &= "CREATE TABLE [dbo].[Product]" & @CRLF $tmpSQLContent &= "(" & @CRLF $tmpSQLContent &= " [ProductId] [uniqueidentifier] DEFAULT NEWID() NOT NULL," & @CRLF $tmpSQLContent &= " [ProductName] [nchar](50) NULL," & @CRLF $tmpSQLContent &= " [ProductDescription] [nchar](3000) NULL," & @CRLF $tmpSQLContent &= " [ProductPrice] MONEY NULL" & @CRLF $tmpSQLContent &= ") ON [PRIMARY]" & @CRLF $tmpSQLContent &= "GO" & @CRLF $tmpSQLContent &= "" & @CRLF $tmpSQLContent &= "-- Table Sales" & @CRLF $tmpSQLContent &= "CREATE TABLE [dbo].[Sales]" & @CRLF $tmpSQLContent &= "( " & @CRLF $tmpSQLContent &= " [SaleId] [uniqueidentifier] DEFAULT NEWID() NOT NULL," & @CRLF $tmpSQLContent &= " [SaleName] [nchar](50) NULL," & @CRLF $tmpSQLContent &= " [SaleInfo] [nchar](3000) NULL," & @CRLF $tmpSQLContent &= " [SaleMoney] MONEY NULL" & @CRLF $tmpSQLContent &= ") ON [PRIMARY]" & @CRLF $tmpSQLContent &= "GO" & @CRLF $tmpSQLContent &= "" & @CRLF $tmpSQLContent &= "SET ANSI_NULLS ON" & @CRLF $tmpSQLContent &= "GO" & @CRLF $tmpSQLContent &= "SET QUOTED_IDENTIFIER ON" & @CRLF $tmpSQLContent &= "GO" & @CRLF $tmpSQLContent &= "" & @CRLF $tmpSQLContent &= "-- The End" & @CRLF Local $hOpen = FileOpen($tmpSQLfile, 2 + 8 + 128) FileWrite($hOpen, $tmpSQLContent) Return FileClose($hOpen) EndFunc ;==>_SetTMPsql Func _OnExit() Exit FileDelete($tmpSQLfile) EndFunc ;==>_OnExit mikell
  9. I am trying to rebuild an old single signon script that has been giving us a bit of trouble lately. I didn't write it and it was written in another script language. If the target program is already open it will have the current user's last name as part of the window text, which I am trying to compare against the user name to see if I should just WinActivate or Process Close and start the program over. I will be provided the username like "jones", or "smith" and the title check works fine for last names (with no spaces), but if the last name DOES contains spaces, say "Nom De Plume", then all I will be given as a username is "nomdeplume". Is there any way (via a regex maybe) that I can still check the text on the screen and somehow ? I have been reading about the Advanced (4) mode of WinTitleMatchMode, but it is over my head. Any help is appreciated. Here is a small reproducer script: Opt("WinTitleMatchMode", -1) Run("Notepad") WinWait("[CLASS:Notepad]", "", 10) Send ("Smith" & @CRLF & "Jones" & @CRLF & "Nom De Plume" & @CRLF) If WinExists("[CLASS:Notepad]", "jones") Then MsgBox(0,"FOUND","Found Jones") EndIf If WinExists("[CLASS:Notepad]", "nomdeplume") Then MsgBox(0,"FOUND","Found Nom De Plume") EndIf
  10. Currently I have Switch StringLen($Serial) Case 0 Return "Please Enter a Serial #" Case 1 To 6 Return "UNKNOWN or INCORRECT" Case 7 Select Case StringLeft($Serial, 2) = "79" $Valid = "Device 1" Case StringLeft($Serial, 3) = "350" $Valid = "Device 2" Case StringRegExp($Serial, "72[HR](.*)") ; Match 72H and 72R $Valid = "Device 3" Case Else $Valid = "UNKNOWN or INCORRECT" EndSelect Case 8 Select Case StringRegExp($Serial, "\d[A-Z](.*)") ; Match a Digit (0-9), then a letter $Valid = "Device 4 short format" Case Else $Valid = "UNKNOWN or INCORRECT" EndSelect EndSwitch Which I'm using to match a number followed by a letter then any number of digits up to a string length of 8 characters. However I don't want it to match strings such as 1234A123 only 1D123456 Is there anyway to do this using a flag or am I limited to having to use StringLeft()?
  11. Hello guys, i have a problem in this regex because its not groupping right. Look: (\d{1,2}\s?[\055|\056|\057|\134]\s?\d{1,2}(\s?[\055|\056|\057|\134]\s?\d{2,4})?) It checks for day or dayday, month or monthmonth, yearyear or yearyearyear+year. separated with or without space and the characters "\/.-" But, a problem! I tried to regex the date with or without the "separator + year" Eg: 05/05 or 05/05/05, but when i have 05/05/05, regex are separating 05/05 and /05 Iam using group "()" wrong? Need help here Thx adv! ~~EDIT: Script used: (from autoitscript.com/forum/topic/129697-split-string-by-regular-expression/#comment-901335) #include <Array.au3> Local $sString = ClipGet() ; Extract the delimiters $aDelim = StringRegExp($sString, '(\d{1,2}\s?[\055|\056|\057|\134]\s?\d{1,2}(\s?[\055|\056|\057|\134]\s?\d{2,4})?)', 3) ; Split the string on the delimiters $aParts = StringSplit(StringRegExpReplace($sString, '(\d{1,2}\s?[\055|\056|\057|\134]\s?\d{1,2}(\s?[\055|\056|\057|\134]\s?\d{2,4})?)', "$<SEPARATOR>$"), "$<SEPARATOR>$", 3) ; Add the delimter to the start of the part For $i = 0 To UBound($aParts) - 1 ;$aParts[$i + 1] = $aDelim[$i] & $aParts[$i + 1] Next ; Set the count $aParts[0] = UBound($aParts) ; Display the result _ArrayDisplay($aParts) _ArrayDisplay($aDelim) Results in array: (the array parts in all string is ok; but the string delimitator himself is getting separated in every string that have year together) String used as test: Cheers.
  12. Hello , I am trying to find the best way to spilt this string: :<nick>!<host mask> PRIVMSG <channel/nick> :<message> into an array like this: Global Enum $SENT_BY, $HOST_MASK, $SENT_TO, $MESSAGE $aArray[$SENT_BY] = "<nick>" $aArray[$HOST_MASK] = "<host mask>" $aArray[$SENT_TO] = "<channel/nick>" $aArray[$MESSAGE] = "<message>" (Stuff between <> is dynamic) I can do that with inefficient code but I think it is possible to do it more efficiently with RegEx Thanks in Advance! TD P.S Yeah, that is the raw format of a message received in IRC
  13. Hi ppl, im trying to do a script that reads an .au3 file, and retrieves all variables in it, then i work with that. This is what i got so far #include <Array.au3> $File = FileOpenDialog('Au3 Var Searcher', @ScriptDir, 'Au3Files (*.au3)') $FileOpen = FileOpen($File) $FileRead = FileRead($FileOpen) FileClose($FileOpen) Search() Func Search() Local $aArray = StringRegExp($FileRead, '$[:alnum:][:blank:]', 2) ConsoleWrite(' - '& $aArray[0] &' - '&@MSEC&@CRLF) _ArrayDisplay($aArray) EndFunc So we know it has to start with $, and have [:alnum:] until [:blank:] or simply not [:alnum:] anymore. Or is there another way? Thanks in advance
  14. I have a String that I'm trying to get the text between of. The string is something like user/Dgameman1" class="author I'm trying to get everything between user/ and " class="author This is the code I currently have StringRegExp($HTML,'(\/user\/)(.+?)(\" class)', 3)But for whatever reason, this isn't returning the value and I'm not sure how to go about fixing the Regex Expression. Thank you guys so much
  15. So a few times I have wanted/needed some sort of input validation (aka input mask) we had an old udf somebody made that sort of worked but was hard to use and a bit limited. As I started to learn regex of late sort of by chance I realized it could be used as a pretty great input validation. But it was a lot of code if you wanted to do it for multiple fields. So wrapped it up into a little function and sharing. Far from a UDF so putting in the example section, and I am not sure if what I am doing is even "good code" but it works for me and hope it is usefull for somebody. Basic RegEx knowledge will help you make the most of this, but a few examples are included below in the code snippet. #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Test GUI", 618, 276, 192, 124) $Label1 = GUICtrlCreateLabel("Test GUI", 168, 24, 47, 17) $Button1 = GUICtrlCreateButton("Toggle Validation", 290, 24, 110, 40) $Input1 = GUICtrlCreateInput("Max 10 Characters", 40, 72, 553, 21) $Input2 = GUICtrlCreateInput("Numb3rs 0nly", 40, 97, 553, 21) $Edit1 = GUICtrlCreateEdit("Max 10 Chars Numbers Only + Auto Line Break", 40, 120, 553, 105) GUISetState(@SW_SHOW) $iToggle = 1 While 1 Sleep(10) If Mod($iToggle, 2) = 0 Then ;Example 1 Limit to 10 Characters _GUIRegExValidate($Input1, "(.{10})(.)", "$1") ;Example 2 Can only type numbers _GUIRegExValidate($Input2, "[^\d]", "") ;Example 3 Combind More Than One On Same Input limit to 10 characters, limit to numbers only, line break @ 10 characters to new line _GUIRegExValidate($Edit1, "(.{10})(.)", "$1" & @CRLF) _GUIRegExValidate($Edit1, "[^\d\r\n]", "") EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $iToggle = $iToggle + 1 EndSwitch WEnd Func _GUIRegExValidate($sInputLabel, $sRegExCapture, $sRegExReplace) $Step1Read = GUICtrlRead($sInputLabel) $Step2Validate = StringRegExpReplace($Step1Read, $sRegExCapture, $sRegExReplace) If @Extended = 0 Then Return GUICtrlSetData($sInputLabel, $Step2Validate) EndFunc Or per recommendation you can use it with the GuiRegisterMsg so that you can only process the RegEx when you make a chance instead of in a constant loop. #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Test GUI", 618, 276, 192, 124) $Label1 = GUICtrlCreateLabel("Test GUI", 168, 24, 47, 17) $Button1 = GUICtrlCreateButton("Toggle Validation", 290, 24, 110, 40) $Input1 = GUICtrlCreateInput("Max 10 Characters", 40, 72, 553, 21) $Input2 = GUICtrlCreateInput("Numb3rs 0nly", 40, 97, 553, 21) $Edit1 = GUICtrlCreateEdit("Max 10 Chars Numbers Only + Auto Line Break", 40, 120, 553, 105) GUISetState(@SW_SHOW) $iToggle = 1 GUIRegisterMsg($WM_COMMAND, '_WM_COMMAND') While 1 Sleep(10) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $iToggle = $iToggle + 1 EndSwitch WEnd Func _GUIRegExValidate($sInputLabel, $sRegExCapture, $sRegExReplace) $Step1Read = GUICtrlRead($sInputLabel) $Step2Validate = StringRegExpReplace($Step1Read, $sRegExCapture, $sRegExReplace) If @Extended = 0 Then Return GUICtrlSetData($sInputLabel, $Step2Validate) EndFunc Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam) If Mod($iToggle, 2) = 0 Then ;Example 1 Limit to 10 Characters _GUIRegExValidate($Input1, "(.{10})(.)", "$1") ;Example 2 Can only type numbers _GUIRegExValidate($Input2, "[^\d]", "") ;Example 3 Combind More Than One On Same Input limit to 10 characters, limit to numbers only, line break @ 10 characters to new line _GUIRegExValidate($Edit1, "(.{10})(.)", "$1" & @CRLF) _GUIRegExValidate($Edit1, "[^\d\r\n]", "") EndIf EndFunc
  16. I was working on something last night and decided to use StringRegExpReplace() for a config file, I never noticed that you cant just "overwrite" the file with the update so easily it required a few more pieces of code to work properly. Is this the simplest way (what I used) and while I searched for it and did not find it do we have or will we have a RegEx equivalent for _ReplaceStringInFile()? $sFile = FileRead(@ScriptDir & "\test.txt") $hFile = FileOpen(@ScriptDir & "\test.txt", 2) $sNewContent = StringRegExpReplace($sFile, "(test)", "new$1") FileWrite($hFile, $sNewContent) FileClose($hFile)
  17. I could use a lesson in laziness... I sometimes come across this problem where I think I need to use regex 'lazy' and the stuff I'm trying doesn't work, cos I need an eye-opener example for one of my typical problems... As an example a string of text where I *only* want the red spaces selected (or have a usable $1 and $2) after each piece of "quoted text" longer than 6 characters: "12345!" Txt "12345!" Txt "123456789!" Txt "12345!" Txt "12345!" Txt "12345678!" TxtThe problem with what I'm trying is that it seems greedy and the selection doesn't stop at the first quote character (going backwards)... I try '(?U)' and other stuff, but not seeing the light yet... This is *not* what I want. I want the "12345!" instances ignored... (BTW: don't use '\d', cos it could be anything inside the quotes) TIA
  18. Hello, I'm back to working on my RegEx skills and trying to come up with something to reformat file directory / file paths that are coming from other applications so that I can feed the resulting list into another script that I came up with. My problem is that I have been testing my RegEx by using https://regex101.com/ with PCRE(PHP). To date it has worked well for me, however, I have hit a stumbling block. In the example below the RegEx on line 158 when applied to pattern "C:\S\*" should pass through the ELSE on line 162 and then get trapped by line 175. Instead, it flows to 159 and then 188. I'm going cross-eyed and I can't spot the problem in the RegEx, If you have a moment and have experience with this kind of thing, would you please take a quick look and tell me what you think is wrong besides this being probably the ugliest way to go about a simple task. The task is simply end up with either a full file path or a directory without a trailing backslash. Thanks in advance, Casey EDIT - [RESOLVED] Replaced script block with corrections, though I am not at all happy with how sloppy it is and I am going to rewrite after learning quite a bit in the process. I just didn't want to leave a truly broken bit out here on the site. #include <Array.au3> #include <Constants.au3> #include <MsgBoxConstants.au3> ; Where we have a full path to a file including file extension Local $aArray[1] = ["C:\S\File.txt"] _ArrayAdd($aArray, "C:\S\Some File.txt") _ArrayAdd($aArray, "C:\Windows\winsxs\FileMaps\program_files_business_objects_common_3.5_bin_d4f3c306b49748a7.cdf-ms") _ArrayAdd($aArray, "C:\S\0_Some File.cdf-ms") ; Where the training backslash is missing from a directory - This is good, DirGetSize format _ArrayAdd($aArray, "C:\S") ; Where the training backslash exists on a directory - This is bad, DirGetSize won't work _ArrayAdd($aArray, "C:\S\") ; Where the path ends in an * - This is bad, DirGetSize value less than C:\S _ArrayAdd($aArray, "C:\S\*") ; Where the path ends in an *.* - This is real bad, DirGetSize won't work and attrib is a laundry list _ArrayAdd($aArray, "C:\S\*.*") _ArrayAdd($aArray, "C:\Program Files (x86)\No Problem\*.*") _ArrayAdd($aArray, "C:\Program Files (x86)\No Problem\*.txt") _ArrayAdd($aArray, "C:\Program Files (x86)\No Problem\a.txt") _ArrayAdd($aArray, "C:\Users\A.Problem") _ArrayAdd($aArray, "C:\Users\A.Problem") ;======================================================================================================================================== ; A must as we are working with Winternal's Process Monitor Output and Handles.exe Output Local $bArray = _ArrayUnique($aArray) _ArrayColInsert($bArray, 1) _ArrayColInsert($bArray, 2) _ArrayDisplay($bArray, "Array @ Beginning") ;======================================================================================================================================== $Cnt = 0 For $i = 0 To UBound($bArray) - 1 $Cnt = $Cnt + 1 Next $Cnt = $Cnt - 1 For $i = 1 To $Cnt Local $LenRegEx = 0 Local $LenArrayItem = 0 ;Test for something that might look like a file extension, greedy, but length of file extension and composition is unknown ;Example: C:\Windows\winsxs\FileMaps\program_files_business_objects_common_3.5_bin_d4f3c306b49748a7.cdf-ms Global $cArray = StringRegExp($bArray[$i][0], "^\w:\\[\. \( \) \w \\ \-]+\\[\w \\ \.-]+", 2) If @error <> 0 Then ;_MsgBox("FIRST REGEX FAILED AND SET ERROR" & @CRLF & @CRLF & "$LenRegEx = " & @CRLF & @CRLF & $LenRegEx & @CRLF & @CRLF & "$LenArrayItem = " & @CRLF & @CRLF & $LenArrayItem) $cArray = StringRegExp($bArray[$i][0], "^\w:\\[\. \(\)\w\\\-]+\\[^\w \\ -]+", 2) If @error <> 0 Then Local $LenRegEx = 0 Local $LenArrayItem = StringLen($bArray[$i][0]) ;_MsgBox("SECOND REGEX FAILED AND SET ERROR" & @CRLF & @CRLF & "$LenRegEx = " & @CRLF & @CRLF & $LenRegEx & @CRLF & @CRLF & "$LenArrayItem = " & @CRLF & @CRLF & $LenArrayItem) $bArray[$i][2] = @ScriptLineNumber Else Local $LenRegEx = StringLen($cArray[0]) Local $LenArrayItem = StringLen($bArray[$i][0]) ;_MsgBox("$LenRegEx = " & @CRLF & @CRLF & $LenRegEx & @CRLF & @CRLF & "$LenArrayItem = " & @CRLF & @CRLF & $LenArrayItem) $bArray[$i][2] = @ScriptLineNumber EndIf Else Local $LenRegEx = StringLen($cArray[0]) Local $LenArrayItem = StringLen($bArray[$i][0]) ;_MsgBox("$LenRegEx = " & @CRLF & @CRLF & $LenRegEx & @CRLF & @CRLF & "$LenArrayItem = " & @CRLF & @CRLF & $LenArrayItem) $bArray[$i][2] = @ScriptLineNumber EndIf If $LenRegEx == $LenArrayItem Then ;_MsgBox("Some are FileGetSize and DirGetSize Compatible " & @CRLF & @CRLF & $bArray[$i][0] & @CRLF & @CRLF & $cArray[0]) $bArray[$i][2] = @ScriptLineNumber $IsThereAnAsterixOrSlash = StringMid($bArray[$i][0], $LenArrayItem, 1) ;_MsgBox("$IsThereAnAsterixOrSlash = " & $IsThereAnAsterixOrSlash) $bArray[$i][2] = @ScriptLineNumber Select Case $IsThereAnAsterixOrSlash = "*" If StringMid($bArray[$i][0], ($LenArrayItem - 1), 2) = "\*" Then ;_MsgBox("A \* existed " & StringLen($bArray[$i][0])) $bArray[$i][2] = @ScriptLineNumber $bArray[$i][1] = StringTrimRight($bArray[$i][0], 2) ;_ArrayDisplay($bArray, @ScriptLineNumber) Else $IsItAsterixDotAsterix = StringMid($bArray[$i][0], $LenArrayItem - 3, 4) ;_MsgBox("$IsItAsterixDotAsterix: " & $IsItAsterixDotAsterix) $bArray[$i][2] = @ScriptLineNumber If $IsItAsterixDotAsterix = "\*.*" Then ;_MsgBox("\*.* " & @CRLF & @CRLF & $IsItAsterixDotAsterix) ;_MsgBox("StringLen($bArray[$i][0] " & @CRLF & @CRLF & StringLen($bArray[$i][0]) & @CRLF & @CRLF & "StringLen($bArray[$i][0] - 4 " & @CRLF & @CRLF & StringLen($bArray[$i][0]) - 4) $bArray[$i][1] = StringTrimRight($bArray[$i][0], StringLen($bArray[$i][0]) - 4) ;_MsgBox("A * or \ existed " & $bArray[$i][0]) $bArray[$i][2] = @ScriptLineNumber ;_ArrayDisplay($bArray, @ScriptLineNumber) ElseIf StringTrimRight($IsItAsterixDotAsterix, 2) = "\*" Then ;_MsgBox("\* " & @CRLF & @CRLF & $IsItAsterixDotAsterix) ;_MsgBox("StringLen($bArray[$i][0] " & @CRLF & @CRLF & StringLen($bArray[$i][0]) & @CRLF & @CRLF & "StringLen($bArray[$i][0] - 4 " & @CRLF & @CRLF & StringLen($bArray[$i][0]) - 2) $bArray[$i][1] = StringTrimRight($bArray[$i][0], StringLen($bArray[$i][0]) - 2) ;_MsgBox("A * or \ existed " & $bArray[$i][0]) $bArray[$i][2] = @ScriptLineNumber ;_ArrayDisplay($bArray, @ScriptLineNumber) Else ;_MsgBox("We shouldn't be able to see this so what's wrong?: " & @CRLF & @CRLF & $bArray[$i][0]) $bArray[$i][2] = @ScriptLineNumber EndIf EndIf Case $IsThereAnAsterixOrSlash = "\" ;_MsgBox("A * or \ existed " & $bArray[$i][0]) $bArray[$i][2] = @ScriptLineNumber $bArray[$i][1] = StringTrimRight($bArray[$i][0], StringLen($bArray[$i][0]) - 1) ;_ArrayDisplay($bArray, @ScriptLineNumber) Case Else ;_MsgBox("We have a good full file path. " & @CRLF & @CRLF & $bArray[$i][0]) $bArray[$i][2] = @ScriptLineNumber $bArray[$i][1] = $bArray[$i][0] ;_ArrayDisplay($bArray, @ScriptLineNumber) EndSelect Else ;=========================================================================================================================== ;Check if no possible file extension by looking if returned regex length equals array element string length ;_MsgBox("$LenRegEx = " & @CRLF & @CRLF & $LenRegEx & @CRLF & @CRLF & "$LenArrayItem = " & @CRLF & @CRLF & $LenArrayItem) $bArray[$i][2] = @ScriptLineNumber ; Could be: C:\S\* $dArray = StringRegExp($bArray[$i][0], "^(.+\\\w+)", 2) If @error <> 0 Then ;_MsgBox("SECOND REGEX FAILED AND SET ERROR") $bArray[$i][2] = @ScriptLineNumber EndIf #cs Full String Match On: C:\S C:\S [return matches source, we have a winner and we already like this guy so we will do nothing to him] #ce $LenRegEx = StringLen($dArray[0]) $LenArrayItem = StringLen($bArray[$i][0]) ;_MsgBox("$LenRegEx = " & @CRLF & @CRLF & $LenRegEx & @CRLF & @CRLF & "$LenArrayItem = " & @CRLF & @CRLF & $LenArrayItem) $bArray[$i][2] = @ScriptLineNumber If $LenRegEx == $LenArrayItem Then ;_MsgBox("DIR NO SLASH " & $dArray[0]) $bArray[$i][2] = @ScriptLineNumber $bArray[$i][1] = $bArray[$i][0] ;_ArrayDisplay($bArray, @ScriptLineNumber) Else $eArray = StringRegExp($bArray[$i][0], "^\w:\\[\. \( \) \w \\ \-]+\\[^\w \\ \.-]+", 2) ;$eArray = StringRegExp($bArray[$i][0], "(?x) ^ \w : \\ [\. \(\)\w\\-]+ \\ [^\w\\ \.-]+", 2) [Same results as above] Thank you for the insight JCHD If @error <> 0 Then ;_MsgBox("THIRD REGEX FAILED AND SET ERROR") $bArray[$i][2] = @ScriptLineNumber $eArray = StringRegExp($bArray[$i][0], "^\w:\\[\. \( \) \w \\ \-]+\\[^\w \\ \.-]?", 2) ; C:\S\ If @error <> 0 Then ;_MsgBox("FOURTH REGEX FAILED AND SET ERROR") $bArray[$i][2] = @ScriptLineNumber $eArray = StringRegExp($bArray[$i][0], "^\w:\\[\. \(\)\w\\\-]+\\[^\w \\ -]+", 2) ; C:\S\*.* -FAILING BC LINE 136 "^(.+\\\w+)" HAS PARTIAL MATCH If @error <> 0 Then ;_MsgBox("FIFTH REGEX FAILED AND SET ERROR") $bArray[$i][2] = @ScriptLineNumber Local $LenRegEx = 0 Local $LenArrayItem = StringLen($bArray[$i][0]) ;_MsgBox("INSANE ->" & $bArray[$i][0] & "<-") $bArray[$i][2] = @ScriptLineNumber Else Local $LenRegEx = StringLen($eArray[0]) Local $LenArrayItem = StringLen($bArray[$i][0]) ;_MsgBox($eArray[0] & @CRLF & @CRLF & $LenRegEx) $bArray[$i][2] = @ScriptLineNumber ;_ArrayDisplay($bArray, @ScriptLineNumber) EndIf Else Local $LenRegEx = StringLen($eArray[0]) Local $LenArrayItem = StringLen($bArray[$i][0]) ;_MsgBox($eArray[0] & @CRLF & @CRLF & $LenRegEx) $bArray[$i][2] = @ScriptLineNumber ;_ArrayDisplay($bArray, @ScriptLineNumber) EndIf Else Local $LenRegEx = StringLen($eArray[0]) Local $LenArrayItem = StringLen($bArray[$i][0]) ;_MsgBox($eArray[0] & @CRLF & @CRLF & $LenRegEx) $bArray[$i][2] = @ScriptLineNumber ;_ArrayDisplay($bArray, @ScriptLineNumber) If $LenRegEx = $LenArrayItem Then $bArray[$i][1] = $bArray[$i][0] $bArray[$i][2] = @ScriptLineNumber ;_MsgBox("$LenRegEx = " & @CRLF & @CRLF & $LenRegEx & @CRLF & @CRLF & "$LenArrayItem = " & @CRLF & @CRLF & $LenArrayItem) ;_ArrayDisplay($bArray, @ScriptLineNumber) EndIf EndIf $fArray = StringRegExp($bArray[$i][0], "^\w\:\\[\. \(\)\w\\\-]+\\[^\w \\ -]+", 2) If @error <> 0 Then $bArray[$i][2] = @ScriptLineNumber ;_ArrayDisplay($bArray, @ScriptLineNumber) Else Local $LenRegEx = StringLen($fArray[0]) Local $LenArrayItem = StringLen($bArray[$i][0]) ;_MsgBox($fArray[0] & @CRLF & @CRLF & $LenRegEx) $bArray[$i][2] = @ScriptLineNumber ;_ArrayDisplay($bArray, @ScriptLineNumber) If $LenRegEx = $LenArrayItem Then $bArray[$i][1] = StringTrimRight($bArray[$i][0], 4) ;$bArray[$i][1] = $bArray[$i][0] $bArray[$i][2] = @ScriptLineNumber ;_MsgBox("$LenRegEx = " & @CRLF & @CRLF & $LenRegEx & @CRLF & @CRLF & "$LenArrayItem = " & @CRLF & @CRLF & $LenArrayItem) $LenRegEx = 0 ;_ArrayDisplay($bArray, @ScriptLineNumber) Else $gArray = StringRegExp($bArray[$i][0], "^\w\:\\[\. \(\)\w\\\-]+\\[^ \\ -]+", 2) If @error <> 0 Then $bArray[$i][2] = @ScriptLineNumber ;_ArrayDisplay($bArray, @ScriptLineNumber) Else Local $LenRegEx = StringLen($gArray[0]) Local $LenArrayItem = StringLen($bArray[$i][0]) ;_MsgBox("$LenRegEx = " & @CRLF & @CRLF & $LenRegEx & @CRLF & @CRLF & "$LenArrayItem = " & @CRLF & @CRLF & $LenArrayItem) If $LenRegEx = $LenArrayItem Then $bArray[$i][1] = StringTrimRight($bArray[$i][0], 6) ;$bArray[$i][1] = $bArray[$i][0] $bArray[$i][2] = @ScriptLineNumber ;_MsgBox("$LenRegEx = " & @CRLF & @CRLF & $LenRegEx & @CRLF & @CRLF & "$LenArrayItem = " & @CRLF & @CRLF & $LenArrayItem) ;_ArrayDisplay($bArray, @ScriptLineNumber) EndIf EndIf EndIf EndIf $IsThereAnAsterixOrSlash = StringMid($bArray[$i][0], $LenArrayItem, 1) ;_MsgBox($bArray[$i][0] & @CRLF & @CRLF & "->" & $IsThereAnAsterixOrSlash & "<-") $bArray[$i][2] = @ScriptLineNumber Select Case $LenRegEx == $LenArrayItem #cs Full String Match On: C:\S\ C:\S\* #ce If $IsThereAnAsterixOrSlash = "*" Then $bArray[$i][1] = StringTrimRight($bArray[$i][0], 2) ;_MsgBox("An * existed " & $bArray[$i][0]) $bArray[$i][2] = @ScriptLineNumber ;_ArrayDisplay($bArray, @ScriptLineNumber) EndIf If $IsThereAnAsterixOrSlash = "\" Then $bArray[$i][1] = StringTrimRight($bArray[$i][0], 1) ;_MsgBox("A \ existed " & $bArray[$i][0]) $bArray[$i][2] = @ScriptLineNumber ;_ArrayDisplay($bArray, @ScriptLineNumber) Else ;_MsgBox("OUCH Who Knows") $bArray[$i][2] = @ScriptLineNumber EndIf Case Else ;_MsgBox("We shouldn't be able to see this so what's wrong?: " & @CRLF & @CRLF & $bArray[$i][0]) $bArray[$i][2] = @ScriptLineNumber EndSelect EndIf EndIf ;=========================================================================================================================== Next $bArray[0][0] = "*** Source Format of Text ***" $bArray[0][1] = "*** Reformatted Text ***" $bArray[0][2] = "*** Script Line Exited ***" _ArrayDisplay($bArray, "Array @ End") ; #FUNCTION# ==================================================================================================================== ; CUSTOM MSGBOX - ADDS SCRIPT LINE NUMBER AS TITLE FOR DEBUGGING - ADD MSGBOXES TO SOURCE IF NEEDED ; EXAMPLE MSGBOX ;_MsgBox("The value for $stringinput is not as expected == " & $stringinput) Func _MsgBox($sText, $sTitle = @ScriptLineNumber) MsgBox(0, "-" & $sTitle & "-", $sText) EndFunc ;==>_MsgBox ; ===============================================================================================================================
  19. 1) Was testing some code that would add a full stop after a sentence when it thinks it is proper. In my simplified example are just a small range of characters I want to exclude. However, although my code in the tester is what I want, my AutoIt version doesn't respect my exclusions and is adding full stops to the other characters too. #include <Array.au3> $text = 'Possible end of a "sentence."' & @CRLF & @CRLF & 'Possible end of a sentence…' & @CRLF & @CRLF & 'Possible end of a sentence' & @CRLF & @CRLF & 'Possible end of a sentence!' & @CRLF & @CRLF & 'Last sentence.' MsgBox(0,"original text", $text) $_aFull_Stop_missing = StringRegExp( $text, "(.[^.…!\""]\s{2,}.{3})", 3 ) If Not @error Then _ArrayDisplay($_aFull_Stop_missing) For $i = 0 To UBound($_aFull_Stop_missing)-1 $found = $_aFull_Stop_missing[$i] $fix = StringLeft( $found, 1) & "." & StringRight( $found, StringLen($found) -1 ) $text = StringReplace( $text, $found, $fix, 1) Next EndIf MsgBox(0,"processed text", $text) 2) I'm pretty sure I've seen (maybe older) info on how a StringRegExReplace can uppercase/lowercase a result. But I can't get to work any of what I saw... Neither of these are working here: $text = "Http://site.com, Www.domain.org" $result = StringRegExpReplace($text, "(?i)(https?|www)", StringLower("$1") ) ToolTip($result) Sleep(2500) $result = StringRegExpReplace($text, "(?i)(https?|www)", "\L$1" ) ToolTip($result) Sleep(2500) 3) I've had the impression the https://regex101.com tester can give different results depending on the browser? If so, is there a preferred browser? 4) General question: I see both "If Not @error" and "If @error = 0" being used. "If Not @error" reads best to me. Is there a reason to not always use that variation? 5) If I am mostly processing text from the web or pdf, do I have to use a UTF setting in my regex everywhere/anywhere? So far I have not had that impression at all, but the first example made me start thinking if character encoding could be involved... (although adding UTF instructions in the regex didn't help) TIA!!
  20. How to use regular expressions in StringSplit and StringInStr
  21. Hallo Members, I'm looking for a good regex to get the drive letter and the last two folders from a file path, If the path is to long for the label width then show drive + ellipses and two last folders. Drive:\(ellipses)\folder\folder ex. D:\...\folder\folder and when the folder is in the root of the drive then show D:\Folder The test GUI #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.12.0 Author: Mecano Script Function: ELLIPSIS Long path: Drive:\...\Folder\Folder if root then Drive:\Folder #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here $sFile = "F:\Just a folder\in a another folder\and another\This-dir\And-this-dir" $EllipsisPath = StringRegExpReplace($sFile, '\w[a-zA-Z \\]+\\', '') ; <- This needs another regex ;no ellipsis needed, for testing purposes only $sUSB = "K:\Just a folder" $PathforUSB = StringRegExpReplace($sUSB, '\w[a-zA-Z \\]+\\', '') #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Drive + Two last folders of path", 327, 236, 192, 124) $Button1 = GUICtrlCreateButton("Test label", 40, 168, 97, 33) $Label1 = GUICtrlCreateLabel("F:\...\This-dir\And-this-dir", 40, 12, 200, 40) ; <- Looks good but not dynamic GUICtrlSetColor($Label1, 32768) $Label2 = GUICtrlCreateLabel($sFile, 40, 40, 200, 40, $DT_END_ELLIPSIS) ; <- not the last two directorys GUICtrlSetColor($Label2, 16711680) $Label3 = GUICtrlCreateLabel("Var label1", 40, 72, 200, 40) GUICtrlSetColor($Label3, 16711680) $Label4 = GUICtrlCreateLabel("Var label", 40, 104, 200, 40) GUICtrlSetColor($Label4, 16711680) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUICtrlSetData($Label3, $EllipsisPath) ; $DT_END_ELLIPSIS <- works only on GUICtrlCreateLabel GUICtrlSetData($Label4, $PathforUSB) EndSwitch WEnd Thanks in advance
  22. I wrote a program to convert single and double quotes to curly single and double quotes. The program uses regular expression search and replaces to swap the straight quotes to their curly counterparts and to ignore any HTML tags, too. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <FontConstants.au3> Func Curlify($sInput) Local $sOutput = StringRegExpReplace($sInput, "'(?!([^<]+)?>)", "’") $sOutput = StringRegExpReplace($sOutput, "((^|\s+)(<[^>]*>)*)’", "${1}‘") $sOutput = StringRegExpReplace($sOutput, '"(?!([^<]+)?>)', "”") $sOutput = StringRegExpReplace($sOutput, "((^|\s+)(<[^>]*>)*)”", "${1}“") ; Fix nested quotes While StringRegExp($sOutput, "(‘|“)(<[^>]*>)*(’|”)") $sOutput = StringRegExpReplace($sOutput, "((‘|“)(<[^>]*>)*)’", "${1}‘") $sOutput = StringRegExpReplace($sOutput, "((‘|“)(<[^>]*>)*)”", "${1}“") WEnd Return $sOutput EndFunc ;==>Curlify $FormCurly = GUICreate("Form_Curly", 708, 439, 192, 124) $Original = GUICtrlCreateEdit("", 0, 0, 305, 433) GUICtrlSetFont(-1, 9, $FW_NORMAL, 0, "Courier New") ; Set the font of the previous control. GUICtrlSetLimit(-1, 1500000) $Modified = GUICtrlCreateEdit("", 408, 0, 297, 433) GUICtrlSetFont(-1, 9, $FW_NORMAL, 0, "Courier New") ; Set the font of the previous control. GUICtrlSetLimit(-1, 1500000) $Curly = GUICtrlCreateButton("Curly", 320, 64, 75, 25) $Reset = GUICtrlCreateButton("Reset", 320, 164, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Curly GUICtrlSetData($Modified, Curlify(GUICtrlRead($Original))) Case $Reset GUICtrlSetData($Original, "") GUICtrlSetData($Modified, "") Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd So why am I posting a question about a program that works? This regex: $sOutput = StringRegExpReplace($sOutput, "((^|\s+)(<[^>]*>)*)’", "${1}‘") should be able to be rewritten without the "+": $sOutput = StringRegExpReplace($sOutput, "((^|\s)(<[^>]*>)*)’", "${1}‘") Same goes for the one to do double quotes, obviously. However, if I remove the "+" from the "\s" in the regex, the program will fail in some cases. Something like <b>’<i>Don’t</i>’</b> at the beginning of a line won't get fixed. I suspect it's got something to do with the fact the the previous character (aside from the HTML tags) is a newline. The "\s" should work just fine with newlines. I'm stumped because the regex without the "+" modifier works fine on http://www.regextester.com/ when I test it.
  23. Hallo members, Looking for the right regex for password validation, the password must be eight characters long including at least 1 number and includes both lower and uppercase letters and at least 1 special character. € , £ and letters with umlauts, accents, etc. are not allowed. I have made a test gui with two different validations, this is just for testing purposes, but is this right way to do it? '((?=.*\d)(?=.*[A-Z])(?=.*\W).{8,8})'and '([A-Za-z: ]+\$([A-Z0-9]+)([\s]*[A-Za-z: ]+\$([A-Z0-9]+)){0,2})' The test GUI #NoTrayIcon #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.12.0 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Local $GUI, $Password, $Button1, $Button2 $GUI = GUICreate("Form1", 412, 261, 192, 124) $Password = GUICtrlCreateInput("", 96, 32, 193, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD)) GUICtrlSendMsg(-1, $EM_SETCUEBANNER, False, "8 characters") GUICtrlSetLimit(-1, 8, 8) $Button1 = GUICtrlCreateButton("Export", 97, 77, 193, 25) $Button2 = GUICtrlCreateButton("Import", 97, 123, 193, 25) GUISetState(@SW_SHOW) While 1 Local $StringPassw = GUICtrlRead($Password) Local $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 ; Export If $StringPassw = "" Then MsgBox(16, "Error!", "Password can not be empty") GUICtrlSetState($Password, $GUI_FOCUS) ; regex for testing, the password must be eight characters including one uppercase letter, one special character and alphanumeric characters. ElseIf StringRegExp($StringPassw, '((?=.*\d)(?=.*[A-Z])(?=.*\W).{8,8})') Then MsgBox(0, "Strong", "Password is 8 characters including 1 uppercase letter, 1 special character, alphanumeric characters") ; Debug ; Export() GUICtrlSetState($Button1, $GUI_DISABLE) Else MsgBox(64, "Password is not strong!", "Re-type password, Password must be 8 characters including 1 uppercase letter, 1 special character, alphanumeric characters") GUICtrlSetData($Password, "") EndIf Case $Button2 ; Import If $StringPassw = "" Then MsgBox(16, "Error!", "Password can not be empty") ; another regex for testing GUICtrlSetState($Password, $GUI_FOCUS) ElseIf StringRegExp($StringPassw, '([A-Za-z: ]+\$([A-Z0-9]+)([\s]*[A-Za-z: ]+\$([A-Z0-9]+)){0,2})') Then MsgBox(0, "Strong", "Password is 8 characters including 1 uppercase letter, 1 special character, alphanumeric characters") ; Debug ; Import() GUICtrlSetState($Button2, $GUI_DISABLE) Else MsgBox(64, "Password is not strong!", "Re-type password, Password must be 8 characters including 1 uppercase letter, 1 special character, alphanumeric characters") GUICtrlSetData($Password, "") EndIf EndSwitch WEnd searched the forum, but good not find a good example Edit; the password must be eight characters long including at least 1 number and includes both lower and uppercase letters and at least 1 special character. € , £ and letters with umlauts, accents, etc. are not allowed. I need only a single regular expression Thanks in advance
  24. BackRef UDF Working This UDF is made to provide a small interface towards the StringRegExpReplace Autoit function. The extension is very limited but is an easy approach when used properly. Functions User can pass the complete back-reference to a function.The return value from the function is then used to replace the specific group.The final replacement is flexible and the user has full control over it.The final replacement is done automatically till modification isn't required.The optimization is easy and simple.LimitationsThe pattern has to consume the full string.Example Replace the vowels with their ASCII code #include <BackRef.au3> $i_BackRef_Debug = True ;Set Debug to true ; .. Example 1 ============================================================================================================================ ; Replace the vowels with their ASCII code Local $Replaced = RegExBackRef( 'Hello Nice Meeting You', '(.*?)([aeiou])(.*)', "AscW" ) ;The Function is inbuilt If @error Then Exit @error MsgBox ( 64, 'Test', $Replaced ) ; ............ ============================================================================================================================ Make the first Number group equal to second number group if its greater than that ; .. Example 2 ============================================================================================================================ ; The Function replaces the first group with third group if its greater than that Local $Replaced = RegExBackRef( '1223 MaxRange : 150', '(\d+)([^:]+:\h+)(\d+)', "SetMaxRange", '\1:\3', "$v & '\2\3'" ) If @error Then Exit @error MsgBox ( 64, 'Test', $Replaced ) ; The User Defined Function Func SetMaxRange( $iString ) $iString = StringSplit( $iString, ':' , 2) $iString[0] = Int ( $iString [0] ) $iString[1] = Int ( $iString [1] ) If $iString[0] > $iString[1] Then Return $iString[1] Return $iString[0] EndFunc ; ............ ============================================================================================================================ The Function replaces unicode chars with ascii alphabet ; .. Example 3 ============================================================================================================================ ; The Function replaces unicode version with ascii alphabet Local $String = 'Déjà' Local $Replaced While 1 $Replaced = RegExBackRef($String, '(.*?)([àâäéèêë])(.*)', "ReplaceFunc") If $Replaced = -1 Or @error Then ExitLoop $String = $Replaced WEnd MsgBox(64, 'Test', $String) Func ReplaceFunc($sMatch) Switch $sMatch Case "é","è","ê","ë" Return "e" Case "à","â","ä" Return "a" EndSwitch EndFunc ;==>ReplaceFunc ; ............ ============================================================================================================================ Convert the unicode lower-case chars to upper-case ; .. Example 4 ============================================================================================================================ ;Convert these chars to upper-case Local $String = "à æ û ü" MsgBox(64, 'Test', GlobalBackRef($String, '(.*?)([\340-\374])(.*)', "ReplaceUniChar")) Func ReplaceUniChar($sMatch) ;Get the ASCII code of the string $iAscW = AscW($sMatch) ;Return the character preceding the current character by 32 Return ChrW($iAscW - 32) EndFunc ;==>ReplaceUniChar ; ............ ============================================================================================================================ ChangeLog v1.0 -First Release v1.1 -Added Debugging features -Added Global Replacement v1.2 -Added Count parameter v1.3 -Now supports formatting control like \r \n and \t in the replace sequence. Download - UDF(v1.3) Here is the UDF to download in the following 7zip file. Please post comments and do give me feedback for improvements and bugs. v1.3 BackRef(UDF).7z Previous Downloads : 44 Regards Phoenix XL
  25. Hi! anyone with some oracle SQL experience? I want to join 2 tables, where the only possible join is by two different columns. Column A is a twelve character long number, while the other ( B ) is a two character long number. They can ba joined, because A is like .BB......... , So the 2. and 3. char is taken from B (and in no other cases this is possible). I think I should be able to use REGEXP_LIKE but how do I use column data in this function? '.column_name.........' isn't working naturaly. I tried to look around but I'm stuck now. The best would be if I can use the column name in the regex. I thought about manually entering the possible number combinations, but that wold require updates, and I can't allow that. Thank you for your time!