Search the Community
Showing results for tags 'Regex'.
-
Hello all, I have such JSON file (the example is simplified for demonstration, the original one can content about 20000 array blocks or even more). I need the audience help to flip the "Flip_Me" array. { "Example": { "EnableList": true, "Color": true "Flip_Me": [ { "Name": "Test_1", "Type": { "CAT": 1.1, "DOG": 1.2, "FOX": 1.3 }, "Form": { "ABC": 1.4, "CDE": 1.5, "NON": 1.6 } }, { "Name": "Test_2", "Type": { "CAT": 2.1, "DOG": 2.2, "FOX": 2.3 }, "Form": { "ABC": 2.4, "CDE": 2.5, "NON": 2.6 } }, { "Name": "Test_3", "Type": { "CAT": 3.1, "DOG": 3.2, "FOX": 3.3 }, "Form": { "ABC": 3.4, "CDE": 3.5, "NON": 3.6 } } ] } } Thanks
-
Hi everyone, I have this string: "main_lot 0x111” & @CRLF & “main_version 0xABC” & @CRLF & “main_number 0xDEAD123” & @CRLF & “main_version 0x333" And I'm trying to extract one specific hexadecimal number, actually main_version from this string by using StringRegExp: How to get 'ABC' from it? I'm not sure if the original string uses @CRLF, @CR or @LF as a line breaks (received from linux over ssh plink.exe) I have tried this code but it doesn't work #include <Array.au3> $sLog = "main_lot 0x111” & @CRLF & “main_version 0xABC” & @CRLF & “main_number 0xDEAD123” & @CRLF & “main_version 0x333" $aVer = StringRegExp($sLog, "main_version\h*(.+)(?:0[xX][[:xdigit:]])", 3) _ArrayDisplay($aVer)
-
Inspired by PHP's preg_split. Split string by a regular expression. Also supports the same flags as the PHP equivalent. v1.0.1 Example: #include "StringRegExpSplit.au3" StringRegExpSplit('splitCamelCaseWords', '(?<=\w)(?=[A-Z])') ; ['split', 'Camel', 'Case', 'Words']
-
Is there a way to output the regex matches into a file? I have a script to compare two files and check for regex matches. I want to output the matching regex of 'testexample.txt' to another file. #include <MsgBoxConstants.au3> #include <Array.au3> $Read = FileReadToArray("C:\Users\admin\Documents\testexample.txt") $Dictionary = FileReadToArray("C:\Users\admin\Documents\example.txt") For $p = 0 To UBound($Dictionary) - 1 Step 1 $pattern = $Dictionary[$p] For $i = 0 To UBound($Read) - 1 Step 1 $regex = $Read[$i] If StringRegExp($regex, $pattern, 0) Then MsgBox(0, "ResultsPass", "The string is in the file, highlighted strings: " ) Else MsgBox(0, "ResultsFail", "The string isn't in the file.") EndIf Next Next
- 2 replies
-
- stringregexp
- regex
-
(and 1 more)
Tagged with:
-
Hello, I need some help to parse the Green highlighted value with from below text: RESISTOR THICK FILM 4.64K ±1% 1/4W ±100PPM/°C 1206 SMT RESISTOR THICK FILM 3.83K ±1% 1/4W ±100PPM/°C 1206 SMT RESISTOR CARBON FILM 22K ±10% 1/2W AXIAL THT RESISTOR WIREWOUND 22 ±5% 3W ±30PPM/°C AXIAL THT RESISTOR METAL OXIDE 4.7K ±5% 2 W ±300PPM/°C AXIAL THT RESISTOR THICK FILM 0 1/8W 0805 SMT I am using positive look behind.: (?<=FILM|WOUND|OXIDE).+ Can only pull this off: 4.64K ±1% 1/4W ±100PPM/°C 1206 SMT 3.83K ±1% 1/4W ±100PPM/°C 1206 SMT 22K ±10% 1/2W AXIAL THT 22 ±5% 3W ±30PPM/°C AXIAL THT 4.7K ±5% 2 W ±300PPM/°C AXIAL THT 0 1/8W 0805 SMT I'm trying the \b word boundary to no avail at this point. Appreciate if anyone would guide me on this?
-
Im creating a code that will work in this sequence: 1. Copy the text (question) in one atea of the screen 2. Catch the 2 strings (number) 3. Multiply the 2 strings ( $1*$2) 4. Click the next area to put the answer 5. Paste the answer This is my code MouseClick($MOUSE_CLICK_LEFT, 479, 802, 3, 1) ;Clicking all of the text Send("^c") $x = StringRegExpReplace(ClipGet(), 'What is (\d*) x (\d*) \?$', "$1*$2") MouseClick($MOUSE_CLICK_LEFT, 480, 844, 1, 1) ClipPut($x) Send("^v") However the output is this $1*$2 How can I make it solve itself? Because I tried this code: MouseClick($MOUSE_CLICK_LEFT, 479, 802, 3, 1) ;Clicking all of the text Send("^c") MouseClick($MOUSE_CLICK_LEFT, 480, 844, 1, 1) $x = Execute(StringRegExpReplace(ClipGet(), 'What is (\d*) x (\d*) \?$', "$1*$2")) ClipPut($x) Send("^v") Output is just blank text
-
I have an XML file and every time there are three lines in a row with only <null/> in them, i want to insert a fourth line with <null/>. Each line starts with 3 white spaces, followed by <null/> and ends with a white space followed by CR LF. The presence of the three lines as described is unique to the points where I want to insert a line in this document. I'm trying to figure out how to apply the repeating part of a regex {1,4} but apply it to this whole segment. So far I have the below which picks up an individual line ok: ^\s{3}<null/>\s\r\n I tried wrapping it all in braces () then adding {3} but I'm obviously getting something wrong. Attached is a section from the xml file with a block of nulls that should be matched if anyone would like to have a look. Help_From_Forum.xml
-
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
-
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.
-
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!
-
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
-
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!
- 4 replies
-
- regex
- global vars
-
(and 3 more)
Tagged with:
-
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.
-
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
-
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.
-
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!
- 4 replies
-
- regex
- regular expression
-
(and 1 more)
Tagged with:
-
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
-
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
-
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()?
-
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.
-
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
-
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
-
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