Jump to content

Malkey

MVPs
  • Posts

    2,005
  • Joined

  • Last visited

  • Days Won

    8

Community Answers

  1. Malkey's post in [SOLVED] Convert ASCII to HEX? was marked as the answer   
    Here are two methods achieving what you desire.
    #include <String.au3> Local $String = "1234567812345678" Local $Hex = _StringToHex($String) $Hex = StringRegExpReplace($Hex, "(.{0,8})", "1 ") ; Insert a space after ever 8th character. $Hex = StringRegExpReplace($Hex, "(.{0,17}) ", "1" & @LF) ; Replace every 18th character with a linefeed, @LF. MsgBox(0, "Hex", "Original String: " & $String & @LF & " Hex: " & @LF & $Hex) ; Or ; --------------------------------------------------------------- Local $Ascii2Hex = AscToHex("1234567812345678") MsgBox(0, "The Output", $Ascii2Hex) Func AscToHex($strString) Local $ah = "" For $i = 1 To StringLen($strString) $ah &= Hex(Asc(StringMid($strString, $i, 1)), 2) If Mod($i, 8) = 0 Then $ah &= @LF ; Insert a line feed, @LF, after every 8th character. ElseIf Mod($i, 4) = 0 Then $ah &= " " ; Insert a space after ever 4th character EndIf Next Return $ah EndFunc ;==>AscToHex
  2. Malkey's post in Convert a Number with a comma to a point? was marked as the answer   
    Using StringReplace() is fine to blanket convert all commas.
    In case there are any commas in the string that don't need converting, here is a conditional converting method.
    Local $sOrigString = 'When a comma is between digits, replace with a point e.g. StringReplace("1,62918,", ",", ".")' Local $sString = StringRegExpReplace($sOrigString, "(?<=\d),(?=\d)", ".") Local $iReplacements = @extended MsgBox(4096, "", $iReplacements & " replacement" & _ ; $MB_SYSTEMMODAL is 4096 ($iReplacements = 1 ? " was" : "s were") & _ ; Allow for plural or singular grammatically. " made and the new string is:" & _ @CRLF & @CRLF & $sString) ; The RE Pattern:- ; "(?<=\d)," - (Lookbehind assertions) Match an occurrence of a comma, ",", that is preceded by a digit, "\d", but does not include the digit in the match; and, ; ",(?=\d)" - (Lookahead assertions) Matches a comma followed by a digit, "\d", but does not include the digit in the match. ; So, to match a particular comma to convert, there must be a digit on either side of the comma. ; Returns :- ; 1 replacement was made and the new string is: ; ; When a comma is between digits, replace with a point e.g. StringReplace("1.62918,", ",", ".") ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ : Replacement : Comma converted to point.  
  3. Malkey's post in StringExplode behavior after upgrading from 3.3.10.2 to 3.3.12.0 was marked as the answer   
    Looking at the function _StringExplode in String.au3 in the include directory you will see  
    Return StringSplit($sString, $sDelimiter, $STR_NOCOUNT) where $STR_NOCOUNT = 2

    Previous versions of AutoIt has
    Return StringSplit($sString, $sDelimiter, 3) where 3 = 1+ 2 =  $STR_ENTIRESPLIT (1) +  $STR_NOCOUNT (2)

    My advice is to use StringSplit($sTest, @CRLF, 3) in your script instead of _StringExplode($sTest,@CR)

    This appears to be an introduced bug into the  _StringExplode function.

    The extra lines are introduced because  each character in the delimiter string in _StringExplode  will mark where to split the string.   And @CRLF is two characters.
     
  4. Malkey's post in Append to line in file was marked as the answer   
    Using the word "append to line" insinuates hanging something onto the end of the line.
    Your example shows prepending to the lines. That is, adding to the beginning of each line.

    So, here is an example of adding "word1 " to the beginning of each line in a file.
    #include <Array.au3> #include <File.au3> _FileCreate("test.txt") FileWrite("test.txt", "word" & @CRLF & "word" & @CRLF & "word") Local $a[1] _FileReadToArray("test.txt", $a) _ArrayDisplay($a) For $i = 1 To UBound($a) - 1     $a[$i] = "word1 " &  $a[$i] ; Prepend "word1 " to each array element. Next _FileWriteFromArray("test.txt", $a, 1) ConsoleWrite(FileRead("test.txt") & @CRLF)
  5. Malkey's post in StringRegExpReplace - Help with CSV file and replacing a comma :) was marked as the answer   
    Another way to delete multiple comas within multiple double quotes.
    $string = '"this,is,a,test",3/1/15 11:49:11 AM,COMPUTER01,10.0.0.6,User-defined Rules:test .10,deny read,"\Device\HarddiskVolumeShadowCopy3455\Applications\APPS\Test\shared\driving\predrivingscreening\AArchive\Shiller,Ron,09\INSTRUCTION.TXT",,_,10.110.69.16,C:\Program Files\Veritas\NetBackup\bin\bpbkar32.exe,",",' & "'File' class or access,Notice,OAS,My Organization\Servers\Servers\,1092" ; Result=     "thisisatest",3/1/15 11:49:11 AM,COMPUTER01,10.0.0.6,User-defined Rules:test .10,deny read,"\Device\HarddiskVolumeShadowCopy3455\Applications\APPS\Test\shared\driving\predrivingscreening\AArchive\ShillerRon09\INSTRUCTION.TXT",,_,10.110.69.16,C:\Program Files\Veritas\NetBackup\bin\bpbkar32.exe,"",'File' class or access,Notice,OAS,My Organization\Servers\Servers\,1092 $string = Execute('"' & StringRegExpReplace($string, '(".+?")', '" & StringReplace(""\1"",",","") & "') & '"') ConsoleWrite($string & @LF)
  6. Malkey's post in Regex / SRE conditional was marked as the answer   
    Try this RE pattern
    '(?i)href="([^#"]+).+?class="ValuesLst"'
  7. Malkey's post in Need Assistance with a Constant Loop. was marked as the answer   
    For FileWritetoLine() to work, the file must exist and the line number being written to must exist in the file.
     
    In this example,  press Esc key to stop script and display contents of text file.
    ;;aol.com is the site im using for this demonstaration #include <IE.au3> #include <File.au3> #include <FileConstants.au3> HotKeySet("{ESC}", "Terminate") ; Press Esc key to stop script and display contents of text file. Global $sFileName = @ScriptDir & "\browser.txt" If FileExists($sFileName) Then FileDelete($sFileName) Local $hFileOpen = FileOpen($sFileName, $FO_OVERWRITE + $FO_CREATEPATH) ; Create file If $hFileOpen = -1 Then     MsgBox(0, "", "An error occurred with the FileOpen().")     Exit EndIf FileWrite($hFileOpen, "Title") ; Create line 1 in the file FileClose($hFileOpen) While 1     Sleep(250)     $oIEb = _IEAttach("Aol")     $title = _IEPropertyGet($oIEb, "title")     _FileWriteToLine($sFileName, 1, $title, 1) WEnd Func Terminate()     ShellExecute($sFileName)     Exit EndFunc   ;==>Terminate Edit: Added $title = _IEPropertyGet($oIEb, "title")
  8. Malkey's post in _Dateadd not working was marked as the answer   
    Welcome
    It appears you were progressively adding one month onto the previous answer. So  February 28 plus 1 month equals March 28.
    #include <Date.au3> #include <MsgBoxConstants.au3> $cycles = 4 $stdt = "2015/01/31" $repeat = 1 Do     $stdt1 = _DateAdd('m', $repeat, $stdt)     $stdt1f = _DateTimeFormat($stdt1, 2)     MsgBox(0, '', $stdt1 & @CRLF & $stdt1f)     ;$stdt = $stdt1     $repeat += 1 Until $repeat = $cycles
  9. Malkey's post in How to cut my string into pieces and save each piece to new element of array was marked as the answer   
    Here is one method.
    #include <Array.au3> $string = "42383298472398472389472398472389" $array = StringRegExp($string, "\d{8}", 3) ; From left to right, match 8 digits continuously. _ArrayDisplay($array)
  10. Malkey's post in How to center a Window? was marked as the answer   
    The client area is the inside area of a window excluding the title bar, toolbars, status bar, scroll bars. So instead of "WinGetClientSize" use "WinGetPos", which returns the position and size of a given window.
    #include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> Global $class1, $class2, $msg Global $g_tStruct = DllStructCreate($tagPOINT) ; Create a structure that defines the point to be checked. Global $hWnd;, $windowSize Local $hDLL = DllOpen("user32.dll") $main = GUICreate("", 350, 50, 1200, 750, -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) $lbClass = GUICtrlCreateLabel("", 5, 5, 340, 25) $btnCenter = GUICtrlCreateButton("center window", 5, 25) GUISetState(@SW_SHOW) While 1     Position() ; Update the X and Y elements with the X and Y co-ordinates of the mouse.     $hWnd = _WinAPI_WindowFromPoint($g_tStruct) ; Retrieve the window handle.     If _IsPressed("01", $hDLL) Then         $class1 = _WinAPI_GetClassName($hWnd)         If $class1 <> "AutoIt V3 GUI" And $class1 <> "button" Then             If $class1 <> $class2 Then                 GUICtrlSetData($lbClass, WinGetTitle(""))                 $class2 = WinGetTitle("")             EndIf         EndIf     EndIf     Switch GUIGetMsg()         Case $GUI_EVENT_CLOSE             ExitLoop         Case $btnCenter             Center()     EndSwitch     Sleep(10) WEnd Func Center()     Local $newX, $newY     $windowSize = WinGetPos($class2, "")     $newX = (@DesktopWidth - $windowSize[2]) / 2     $newY = (@DesktopHeight - $windowSize[3]) / 2     WinMove($class2, "", $newX, $newY) EndFunc   ;==>Center Func Position()     DllStructSetData($g_tStruct, "x", MouseGetPos(0))     DllStructSetData($g_tStruct, "y", MouseGetPos(1)) EndFunc   ;==>Position
  11. Malkey's post in Need help to find right pattern for StringRegExp was marked as the answer   
    The trailing space in the $string variable:- "' '<test>a</test> ' & _" will cause a blank array element when using the regex pattern '[^><]+|(<[^>]+>[^<]+</[^>]+>)'.

    Using the regex pattern '[^><h]+|(<[^>]+>[^<]+</[^>]+>)', the blank element in the array will not occur.
    #include <Array.au3> Local $string = _         'rtzrtzrtz' & _         '<test>a</test> ' & _  ; Note trailing space this line.         '<test>b</test>fgdfgd' & _         '<test>c</Test> ' Local $test = _         ' gdf' & _         '<font>My</font>' & _         '<font>Test</font>String' & _         '<font>Hello</font> End' Local $aArray = StringRegExp($string, '[^><\h]+|(<[^>]+>[^<]+</[^>]+>)', 3) ; With \h present, there is no blank element in the array. _ArrayDisplay($aArray) Local $aArray2 = StringRegExp($test, '[^><]+|(<[^>]+>[^<]+</[^>]+>)', 3) _ArrayDisplay($aArray2)
  12. Malkey's post in Converting from AHK was marked as the answer   
    I am totally guessing when the AHK script is run, when the middle mouse button is pressed Ctrl-ALT-c keys are send to the active window.
    On this basis, this example is a modified copy of the example in the help file under the _IsPressed() function.
    Note: When the Esc key is pressed, the script exits.
    #include <Misc.au3> #include <MsgBoxConstants.au3> Local $hDLL = DllOpen("user32.dll") While 1     If _IsPressed("4", $hDLL) Then ; Middle mouse button         ; Wait until key is released.         While _IsPressed("10", $hDLL)             Sleep(250)         WEnd         Send("^!c") ; Send Ctrl-ALT-c     ElseIf _IsPressed("1B", $hDLL) Then ; Esc key         MsgBox($MB_SYSTEMMODAL, "_IsPressed", "The Esc Key was pressed, therefore the application will close in 4 seconds.", 4)         ExitLoop     EndIf     Sleep(250) WEnd DllClose($hDLL)
  13. Malkey's post in Take string until a char was marked as the answer   
    And this.
    Local $str1 = '321321bsidaybsdiaasdb-93218y4n9fnsdudn' Local $str2 = '321321bsidaybsdiaasdb93218y4n9fnsdudn' ConsoleWrite(StringRegExpReplace($str1, '-.*', '') & @CRLF) ; Returns 321321bsidaybsdiaasdb ConsoleWrite(StringRegExpReplace($str2, '-.*', '') & @CRLF) ; Returns 321321bsidaybsdiaasdb93218y4n9fnsdudn
  14. Malkey's post in Create checkbox base on entry in ini file. was marked as the answer   
    Using this "side.ini" ini file:-
    [Block] Key1=side1 Key2=side2 Key3=side3 Key4=side4 Key5=side5 Key6=side6 Key7=side7 Key8=side8 Key9=side9 Key10=side10 Key11=side11 Key12=side12 Key13=side13 Key14=side14 Key15=side15 Key16=side16 Key17=side17 Key18=side18 Key19=side19 Key20=side20 Key21=side21 Key22=side22 Key23=side23 Key24=side24 Key25=side25 Key26=side26 with this example:-
    #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Local $msg, $sResults Local $counter = 0 Local $aIdCB[1000] GUICreate("My GUI Checkbox") While 1     $counter += 1     $Sidename = IniRead("side.ini", "Block", "Key" & $counter, "End")     If $Sidename = "End" Then         $counter -= 1         ExitLoop     EndIf     $aIdCB[$counter - 1] = GUICtrlCreateCheckbox($Sidename, ((Ceiling($counter / 12) - 1) * 125) + 10, (((Mod($counter - 1, 12)) * 30) + 10), 120, 20) WEnd ReDim $aIdCB[$counter] $Button1 = GUICtrlCreateButton("Submit", 255, 100, 73, 30) GUISetState() While 1     $msg = GUIGetMsg()     Switch $msg         Case $Button1             ; Code to process the checkbox information.             For $i = 0 To $counter - 1                 $sResults &= ControlGetText("My GUI Checkbox", "", $aIdCB[$i]) & " is checked - " & (BitAND(GUICtrlRead($aIdCB[$i]), $GUI_CHECKED) = $GUI_CHECKED) & @CRLF             Next             MsgBox(0, "CheckBox Results", $sResults)             $sResults = ""         Case $GUI_EVENT_CLOSE             Exit     EndSwitch WEnd
  15. Malkey's post in Colors not matching: au3info vs. pixelgetcolor() was marked as the answer   
    To be put near the top of your script, below any include files.
    Opt("PixelCoordMode", 1) ;1=absolute, 0=relative, 2=client
  16. Malkey's post in String substitution using placeholders was marked as the answer   
    Using StringFormat function.
    Local $foo = StringFormat("This is %s test, I %s it will produce %s", "a", "hope", "bar") MsgBox(0, "Test1", $foo) ;or Local $first = "a" Local $second = "hope" Local $third = "bar" Local $sFoo = StringFormat("This is %s test, I %s it will produce %s", $first, $second, $third) MsgBox(0, "Test2", $sFoo)
  17. Malkey's post in Delete duplicate lines from a file, but with some exceptions was marked as the answer   
    This _ArrayUniqueEX() function appears to work.
    #include<Array.au3> #include<File.au3> Local $aFile, $aArray Local $InputFile = @ScriptDir & "\Test-2.txt" Local $OutputFile = @ScriptDir & "\Test-2b.txt" $aFile = FileReadToArray($InputFile) ;_ArrayDisplay($aFile) $aArray = _ArrayUniqueEX($aFile) ;_ArrayDisplay($aArray) _FileWriteFromArray($OutputFile, $aArray, 1) ShellExecute($OutputFile) Func _ArrayUniqueEX(Const ByRef $aArray)     Local $sData = ChrW(160), $sSep = ChrW(160)     For $i = 0 To UBound($aArray) - 1         If $aArray[$i] = "" Or _                                                  ; Add blank lines.                 StringInStr($aArray[$i], "%16422%") <> 0 Or _                     ; Add lines with "%16422%" present.                 StringInStr($sData, ChrW(160) & $aArray[$i] & ChrW(160)) = 0 Then ; Add lines that do not already exist in $sData.             $sData &= $aArray[$i] & $sSep         EndIf     Next     Return StringSplit(StringTrimRight(StringTrimLeft($sData, 1), 1), $sSep, 0) EndFunc   ;==>_ArrayUniqueEX
  18. Malkey's post in Using Uez Base 64 String code generator was marked as the answer   
    A possible cause for the error "ERROR: can't open include file <WinAPISys.au3>." is AutoIt release version v3.3.8.1 does not have WinAPISys.au3 in the "...AutoIt3.include" directory.
    The fix would be to update to the latest release version 3.3.10.2.
  19. Malkey's post in Weekdates from _WeekNumberISO() was marked as the answer   
    This example converts a year's week number to the days' dates of that week starting on the Monday - the first day of theweek.
    #include <Date.au3> #include <Array.au3> Local $iWeekNum = 1 Local $Year = 2014 Local $s = _DateFromWeekNumber($Year, $iWeekNum) Local $sDates = _DateFormat($s, "dddd MMM.dd.yyyy") For $i = 1 To 6     $sDates &= "|" & _DateFormat(_DateAdd("D", $i, $s), "dddd MMM.dd.yyyy") Next ;ConsoleWrite($sDates & @LF) Local $aDates = StringSplit($sDates, "|", 2) _ArrayDisplay($aDates) ; The week with the first Thursday of the year is week number 1. ;Returns the date of the Monday of the week number. Func _DateFromWeekNumber($iYear, $iWeekNum)     Local $Date, $sFirstDate = _DateToDayOfWeek($iYear, 1, 1)     If $sFirstDate < 6 Then         $Date = _DateAdd("D", 2 - $sFirstDate, $iYear & "/01/01")     ElseIf $sFirstDate = 6 Then         $Date = _DateAdd("D", $sFirstDate - 3, $iYear & "/01/01")     ElseIf $sFirstDate = 7 Then         $Date = _DateAdd("D", $sFirstDate - 5, $iYear & "/01/01")     EndIf     ;ConsoleWrite(_DateToDayOfWeek($iYear, 1, 1) &"  ")     Local $aDate = StringSplit($Date, "/", 2)     Return _DateAdd("w", $iWeekNum - 1, $aDate[0] & "/" & $aDate[1] & "/" & $aDate[2]) EndFunc   ;==>_DateFromWeekNumber ; Format date ; $sDate, input date in the format yyyy/MM/dd[ hh:mm:ss] Func _DateFormat($sDate, $sFormat)     $hGui = GUICreate("")     $idDate = GUICtrlCreateDate($sDate, 10, 10)     GUICtrlSendMsg($idDate, 0x1032, 0, $sFormat) ; or "dddd, MMMM d, yyyy hh:mm:ss tt"); or "hh:mm tt"     $FormatedDate = GUICtrlRead($idDate)     GUIDelete($hGui)     Return $FormatedDate EndFunc   ;==>_DateFormat
  20. Malkey's post in Save arraydisplay to txt was marked as the answer   
    An example.
    #include <array.au3> #include <File.au3> Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase ;----- Create map.txt file ----------------- Local $dump = "map.txt" If FileExists($dump) = 0 Then FileWrite($dump, "| IP         | Status      |" & @CRLF & _         "----------------------------" & @CRLF & _         "| 10.27.52.5 | disabled    |" & @CRLF & _         "| 10.27.52.6 | disabled    |") ;ConsoleWrite(FileRead($dump) & @LF) ;-----> End of create "map.txt" file ----------------- Local $answer = StringRegExp(FileRead($dump), '((?:\d{1,3}\.){3}\d{1,3})', 3) _ArrayDisplay($answer) Local $SaveTo = "ip.txt" _FileWriteFromArray($SaveTo, $answer) ; ----- View "ip.txt" file and optional clean up files from disk ------------ Local $iPID = ShellExecute($SaveTo) Local $hWin = WinWaitActive($SaveTo, "") Local $Sel = MsgBox(1, "Clean Up", 'Press "Ok" to delete "' & $dump & '" and  "' & $SaveTo & '" files.', 0, $hWin) If $Sel = 1 Then     FileDelete($dump)     FileDelete($SaveTo) EndIf If WinExists($SaveTo) Then ProcessClose($iPID) ;-----> End view "ip.txt" file -----------------
  21. Malkey's post in How get one word in html was marked as the answer   
    Here are another couple of methods base on the "id".
    #include <String.au3> $string = '<span id="lblTotal" class="Bold_Text">26</span>' $found = StringRegExpReplace($string, '(?s).*id="lblTotal"[^>]*>([^<]+)</span>.*', "\1") MsgBox(0, '', $found) and
    #include <IE.au3> Local $Source = '<span id="lblTotal" class="Bold_Text">26</span>' Local $oIE = _IECreate("about:blank", 0, 0, 0, 0) _IEBodyWriteHTML($oIE, $Source) Local $oId = _IEGetObjById($oIE, "lblTotal") MsgBox(0, "Results", $oId.innertext)
  22. Malkey's post in RegExp - question - new line between two different start-up lines was marked as the answer   
    Another fine adjustment needed.

    When the test data has a trailing linefeed as in mLipok's example of post #11, another additional linefeed is added. So "|z"is added to the RE pattern to stop the additional trailing linefeed being added to the output.
    Local $txt = '' $txt &= "TEST1"  & @TAB & "2013-02-08" & @TAB & "some text" & @CRLF ; HERE I want to add new line $txt &= "TEST 2" & @TAB & "2013-2-08" & @TAB & "some text" & @CRLF $txt &= "TEST 2" & @TAB & "2013-01-15" & @TAB & "some text" & @CRLF $txt &= "TEST 2" & @TAB & "2013-01-15" & @TAB & "some text" & @CRLF $txt &= "TEST 2" & @TAB & "2013-01-03" & @TAB & "some text" & @LF ; HERE I want to add new line $txt &= "TEST3"  & @TAB & "2013-1-17" & @TAB & "some text" & @LF ; HERE I want to add new line $txt &= "TEST4"  & @TAB & "2013-1-17" & @TAB & "some text" & @LF $txt &= "TEST4"  & @TAB & "2013-1-18" & @TAB & "some text" & @LF $txt &= "TEST4"  & @TAB & "2013-1-18" & @TAB & "some text" & @LF ; HERE I want to add new line $txt &= "TEST5"  & @TAB & "2013-1-21" & @TAB & "some text" & @LF $txt &= "TEST5"  & @TAB & "2013-1-21" & @TAB & "some text" & @CRLF ; HERE I want to add new line $txt &= "TEST 5" & @TAB & "2013-1-21" & @TAB & "some text" & @LF ;$txt = StringRegExpReplace($txt, '((?<=\v|^)([^\t]+).+\R(?!\2))', '$1' & @crlf )    ; mikell's original ;$txt = StringRegExpReplace($txt, '((?<=\v|^)([^\t]+).+\R(?!\2|\z))', '$1' & @crlf ) ;  mikell's corrected for trailing @LF. $txt = StringRegExpReplace($txt, '(?m)((^[^\t]+)\V+\R(?!\2|\z))', '$1' & @CRLF)      ; Malkey's corrected for trailing @LF. ConsoleWrite($txt & @LF)  
  23. Malkey's post in help searching and editing string was marked as the answer   
    Try this.
    Local $sTestString = StringRegExpReplace(FileRead(@ScriptFullPath), "(?is)^.+#cs\v*(.+)#ce.*$", "\1") ; Extract test data from this script. ;ConsoleWrite($sTestString & @LF) ConsoleWrite(StringRegExpReplace($sTestString, "(?i)(\d+.+?\b(Rd|St|Ave|\(?[A-Z]+-\d+\)?|Dr|Blvd|Ln|Aly|Cres|Ct|Ter))[\s,.]\V*", "\1") & @LF) #cs 482 Albany Shaker Rd Osborne Rd Albany, NY 12211 875 New Scotland Ave opp Whitehall Rd Albany, NY 12208 64 Colvin Ave Central Ave Albany, NY 12206 62 Exchange St Albany, NY 12205 477 Saly Aly Near Whitehall Rd Albany, NY 12209 351 Southern Blvd Albany, NY 12209 477 Delaware Ave Whitehall Rd Albany, NY 12209 553 Terrance Ter, Ontario St Albany, NY 12206 591 Broadway (NY-32) opp Fed Ex Plaza, near Village One Apts Albany, NY 12204 442 Madison Ave Albany, NY 12208 484 Loudon Rd (US-9) near Turner Ln, E of Siena Albany, NY 12211 821 New Scotland Ave near Crescent Dr Albany, NY 12208 #ce Edit: Added "|Blvd"
    Edit2: RE pattern was "(?i)(d+.+?(Rd|St|Ave|(?[A-Z]+-d+)?|Dr|Blvd))V*".
    Just in case a street type exists as a sub-string within the street name I added "b" before street type group and "[s,.]" afterwards. Now, if a street type exists within a street name this street type will not be matched. Although, if there was a terrace called Ter, "553 Ter Ter" would be reduced to "553 Ter" by mistake. However, "477 Saly Aly"  and "553 Terrance Ter" are fine.
  24. Malkey's post in StringRegExp expression help was marked as the answer   
    Using StringRegExpReplace example.
    Local $a = "randomstart - some other random things become randomstart." & @CRLF & _         "random2 - something more of random" & @CRLF & _         "againrandom - again random text" & @CRLF & _         "etc...etc" ; Match everything you want to delete. ; \h* - Match all horizontal white spaces before a minus sign (if any Horiz. white spaces exist), ; -   - match the minus sign, and ; \V* - match all non-vertical white space characters (if any non-vert. white spaces exist). ; and replace the entire match with nothing. $Result = StringRegExpReplace($a, "\h*-\V*", "") ;or ;$Result = StringRegExpReplace($a, "(?m)\h*-.*$", "") ; Using (?m) Multiline: ^ and $ matching start and end of line. ConsoleWrite($Result & @LF) #cs Returns:- randomstart random2 againrandom etc...etc #ce
  25. Malkey's post in StringRegExp get specific letters was marked as the answer   
    Here is my best quess of what you want.
    Local $sStr = "Patrón: LLLAAMMDDXXX en donde, L=(A-Z) letra o caracteres & o Ñ, AA=año, MM=mes, DD=día, X=alfanumérico" & @CRLF & _         "AAAAMMDD; some blablablalba that i dont need" & @CRLF & _ ;         "Patrón: XXAADD o Ñ, AA=año, MM=mes, DD=día, X=alfanumérico" & @CRLF & _ ;         "XXAAMMDD more blablabla that i dont need" MsgBox(0, "Results", StringRegExpReplace($sStr, ".*?([ADLMX]{3,}).*\v*", '"\1" ')) #cs Returns:- "LLLAAMMDDXXX" "AAAAMMDD" "XXAADD" "XXAAMMDD" #ce
×
×
  • Create New...