i am trying to get number from string using this code :
#include <IE.au3> $oIE = _IEAttach ("Edu.corner") Local $aName = "Student name & Code:", $iaName = "0" Local $oTds = _IETagNameGetCollection($oIE, "td") For $oTd In $oTds If $oTd.InnerText = $aName Then $iaName = $oTd.NextElementSibling.InnerText $iGet = StringRegExpReplace($iaName, "\D", "") EndIf Next MsgBox(0, "", $iGet) it was get number like 52503058
But, I want to get only student code 5250. (Different student have different code, sometime its 3 digits, Sometime 4)
This is a program that I made to help my self learn better regular expressions.
There are a lot of other programs/website with the similar functions.
But the main advantage of this program is that you don't have to click a button after every changes.
The program detected changes and react on it.
Match Match of arrays Match and replace Load source data from website Load source data from a website with GET/POST Load text data from file Clear fields Export and Import settings (you can finish the expression a other time, just export/import it) Cheat sheet Generate AutoIt code example code The source code is not difficult and I think most user will understand it.
In the zip file there is a export files (reg back example), you can drag and drop this files on the gui to import it.
Download Regex Toolkit Regex toolkit.zip (Sourcode, example and compiled exe file)
EDIT: Updated to version V1.2.0
Expand and collapse of the cheat sheet (Thanks to Melba23 for the Guiextender UDF) Usefull regular expressions websites links included in the program Text data update time EDIT: Updated to version V1.3.0
Automatic generate AutoIt code Icons on the tab Few minor bug fixes EDIT: Updated to version V1.4.0
Link to AutoIt regex helpfile If the regular expression has a error than the text becomes red Option Offset with Match and array of Matches Option Count with Match and replace Some small minor bug fixed EDIT: Updated to version V1.4.1
Small bug in "create AutoIt" code fixed EDIT: Updated to version V1.4.2
Small bug in "create AutoIt" code fixed Bug with website data fixed
Regex toolkit.zip (Sourcode, example and compiled exe file)
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
Hello, I'm trying to match the second to last line of this:
foo C:\ foobar foobar x C:\temp\dir Last line with chars Here's my code:
$test = 'foo' & @CRLF $test &= 'C:\' & @CRLF $test &= 'foobar' & @CRLF $test &= 'hello' & @CRLF $test &= 'C:\temp\dir' & @CRLF $test &= 'Last line with chars' & @CRLF $test &= @CRLF $test &= @CRLF $result = StringRegExp($test, '(?m)^C:\\.*$Last.*') MsgBox(0, '', $result) I'm trying to match line "C:\temp\dir". Anyone have any ideas?