Jump to content

Search the Community

Showing results for tags 'StringRegExpReplace'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • General
    • Announcements and Site News
    • 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


  • 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


  • Forum
  • AutoIt


  • Community Calendar

Found 20 results

  1. $t = '... 1-347-318-9643 1-347-318-9647 1-347-318-9648 1-347-318-9650 1-347-318-9651 1-347-318-9652 1-347-318-9653 1-347-318-9655 1-347-318- ...' $pattern = '347.*?318.*?9655' $tmp = StringRegExpReplace($t, $pattern, "|||", 1) ConsoleWrite($tmp & @CRLF) However i got this output: ... 1-||| 1-347-318- ... Why i got only that, where is the other string, i thought the output should be this: ... 1-347-318-9643 1-347-318-9647 1-347-318-9648 1-347-318-9650 1-347-318-9651 1-347-318-9652 1-347-318-9653 1-||| 1-347-318- ...
  2. String Replace Help

    So I ran into this crazy "program" that cant be uninstalled via WMI, MSIExec, etc. The only way to uninstall it was from Add/Remove programs manually... Or I found if you find it in the registry under HKCU and run the uninstall string, it will also uninstall. However the string in the registry cant be run directly in a cmd window because of the format errors. It has spaces without quotations, it has invalid characters, etc, etc I know things run different when executed in the registry, so maybe there is a way I can run the regsitry key just like how the system does? If so chime in. Otherwise I did this a crude way using several stringregexpreplace() functions and have it working. The solution feels so barbaric and crude that I wanted to post it so some of you guys better than me can clean up the code, maybe offer alternative ways to do it, or reduce the number of times I process the string. Here is the string right out of the registry: c:\Program Files\Common Files\Microsoft Shared\VSTO\10.0\VSTOInstaller.exe /Uninstall file:///C:/Users/it022565/AppData/Local/Temp/OOBAXTOWordAddIn/ApplicationXtender.AXTO.Word.vsto Here is my cave man scripting to turn this into a run able string. Func _UninstallOld() For $i = 1 to 100 ;Enumerate Registry $sEnumBase = "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" ;Look in HKCU for the uninstall string for the old version $sEnum = RegEnumKey($sEnumBase, $i) If @Error Then Return If $iDebug = 1 Then MsgBox(0, "", $sEnum) If StringInStr(RegRead($sEnumBase & $sEnum, "DisplayName"), "Word Addin") Then ExitLoop Next If $iDebug = 1 Then MsgBox(0, "", $sEnum) $sKey = "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & $sEnum $sKey2 = RegRead($sKey, "UninstallString") If $iDebug = 1 Then MsgBox(0, "Original Install Location", $sKey2) $sKey3 = StringRegExpReplace($sKey2, "(?i)(c:.*exe)", '"$1"') If $iDebug = 1 Then MsgBox(0, "", $sKey3) $sKey4 = StringRegExpReplace($sKey3, "(?i)file:///", "") If $iDebug = 1 Then MsgBox(0, "", $sKey4) $sKey5 = StringRegExpReplace($sKey4, "%20", " ") If $iDebug = 1 Then MsgBox(0, "", $sKey5) $sKey6 = StringRegExpReplace($sKey5, '(?i)((?<!")c:.*vsto)', '"$1"') If $iDebug = 1 Then MsgBox(0, "", $sKey6) RunWait(@ComSpec & ' /c ' & '"' & $sKey6 & ' /s"', "", @SW_HIDE) EndFunc Basically step by step I add quotations, strip bad characters, etc. Kind of proud for using look behind for once Looking forward to what you guys come up with.
  3. Need help to make function better with full infomation #include <Array.au3> #include <File.au3> _TEST(@ScriptFullPath) _TEST("A:") _TEST("A:\B.c") _TEST("D:\E\F\") _TEST("G:\H/../J.k/") _TEST("M:\N\k..J.k") _TEST("D:\E\F\..\G\G\I..J.K.M") Func _TEST($sFilePath) Local $sDrive = "", $sFullPathDir = "", $sDirPath = "", $sDirName = "", $sFileName = "", $sFileNameExt = "", $sExtension = "", $sExt = "" Local $aPathSplit = _PathSplitByRef($sFilePath, $sDrive, $sFullPathDir, $sDirPath, $sDirName, $sFileName, $sFileNameExt, $sExtension, $sExt) ConsoleWrite("!Path IN : " & $sFilePath & @CRLF) ; C:\Windows\System32\etc\hosts.exe ConsoleWrite("- Driver : " & $sDrive & @CRLF) ; C: ConsoleWrite("- DirPath : " & $sFullPathDir & @CRLF) ; C:\Windows\System32\etc\etc ConsoleWrite("- DirPath : " & $sDirPath & @CRLF) ; \Windows\System32\etc\ ConsoleWrite("- DirName : " & $sDirName & @CRLF) ; etc ConsoleWrite("- FileName : " & $sFileName & @CRLF) ; hosts ConsoleWrite("- FileNameExt: " & $sFileNameExt & @CRLF) ; hosts.exe ConsoleWrite("- Extension : " & $sExtension & @CRLF) ; .exe ConsoleWrite("- Ext : " & $sExt & @CRLF & @CRLF) ; exe ;~ ConsoleWrite("!Path IN : " & $aPathSplit[0] & @CRLF) ; C:\Windows\System32\etc\hosts.exe ;~ ConsoleWrite("- Driver : " & $aPathSplit[1] & @CRLF) ; C: ;~ ConsoleWrite("- DirPath : " & $aPathSplit[2] & @CRLF) ; C:\Windows\System32\etc\etc ;~ ConsoleWrite("- DirPath : " & $aPathSplit[3] & @CRLF) ; \Windows\System32\etc\ ;~ ConsoleWrite("- DirName : " & $aPathSplit[4] & @CRLF) ; etc ;~ ConsoleWrite("- FileName : " & $aPathSplit[5] & @CRLF) ; hosts ;~ ConsoleWrite("- FileNameExt: " & $aPathSplit[6] & @CRLF) ; hosts.exe ;~ ConsoleWrite("- Extension : " & $aPathSplit[7] & @CRLF) ; .exe ;~ ConsoleWrite("- Ext : " & $aPathSplit[8] & @CRLF) ; exe ;~ _ArrayDisplay($aPathSplit, "_PathSplit of " & $sFilePath) EndFunc ;==>_TEST Func _PathSplitByRef($sFilePath, ByRef $sDrive, ByRef $sFullPathDir, ByRef $sDirPath, ByRef $sDirName, ByRef $sFileName, ByRef $sFileNameExt, ByRef $sExtension, ByRef $sExt) If StringInStr($sFilePath,"..") Then $sFilePath=_PathFull($sFilePath) Local $aPartOfPath=StringRegExp($sFilePath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", $STR_REGEXPARRAYMATCH) ;~ If @error Then ReDim $aPartOfPath[9] ;~ $aPartOfPath[0] = $sFilePath ;~ EndIf $aPartOfPath[0] = $sFilePath ; C:\Windows\System32\etc\hosts.exe $sDrive = $aPartOfPath[1] ; C: $sFullPathDir = $aPartOfPath[1] & $aPartOfPath[2] ; C:\Windows\System32\etc If StringLeft($aPartOfPath[2], 1) == "/" Then $sDirPath = StringRegExpReplace($aPartOfPath[2], "\h*[\/\\]+\h*", "\/") Else $sDirPath = StringRegExpReplace($aPartOfPath[2], "\h*[\/\\]+\h*", "\\") EndIf $aPartOfPath[2] = $sFullPathDir ; C:\Windows\System32\etc $sDirName=StringReplace($sDirPath,"\","") $sDirName=StringReplace($sDirPath,"/","") $sFileName = $aPartOfPath[3] ; hosts $aPartOfPath[5] = $sFileName ; hosts $sExtension = $aPartOfPath[4] ; .exe $aPartOfPath[7] = $sExtension ; .exe $aPartOfPath[3] = $sDirPath ; \Windows\System32\etc\ $aPartOfPath[4] = $sDirName ; etc $aPartOfPath[6] = $sFileName & $sExtension ; hosts.exe $sFileNameExt = $aPartOfPath[6] ; hosts.exe $sExt = StringReplace($sExtension,".","") ; exe $aPartOfPath[8] = $sExt ; exe Return $aPartOfPath EndFunc ;==>_PathSplitByRef
  4. Hi I am trying to insert line numbers in to a string with this script Func _MyInc () Static Local $i = 0 $i += 1 Return $i EndFunc Exit _InsertLines() Func _InsertLines()     $String = "A" & @CRLF & "B" & @CRLF & "C" & @CRLF & "D" $NewString =  Execute("'" & StringRegExpReplace($String,"[\r\n]*",  "' & _MyInc () & '\1" ) & "'") MsgBox (0, "", $NewString) EndFunc but I get this: 1A23B45C67D8 I never really could master how Execute works here and I always get some working example and make substitutions. But this is the closest i could get...
  5. The idea to use translation api: i used the script from @mikell to build this func: Func _Translate($sFrom, $from, $to) ;thanks to mikell (autoitscript.com) ;https://www.autoitscript.com/forum/topic/182893-prompt-me-how-to-see-the-text-in-the-translation-boxhttpstranslategooglecom/?do=findComment&comment=1313423 Local $url = "https://translate.googleapis.com/translate_a/single?client=gtx" $url &= "&sl=" & $from & "&tl=" & $to & "&dt=t&q=" & $sFrom Local $oHTTP = ObjCreate("Microsoft.XMLHTTP") $oHTTP.Open("POST", $url, False) $oHTTP.Send() Local $sData = $oHTTP.ResponseText $sData = StringRegExpReplace($sData, '.*?\["(.*?)"[^\[]*', "$1" & @CRLF) Return $sData EndFunc ;==>_Translate when i call this func with: $sText='AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying "runtimes" required!' MsgBox(64,'',_Translate($sText,'en','de')) nearly all is seeing here: only the "!" is wrong "\" but when using 'auto' instead of 'en' the result is: 2 lines are appended. So my question is, is it possible to extend the pattern (i never worked with regex) and in best case setting @extended with the detected language? @Trong: as you can see yet i am returning translated text and don't use GuiCtrlSetData to assign it to a EditBox.
  6. 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)
  7. 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: 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
  8. Hi, i wrote a script that can replace multiple strings in a xml file works fine but so slow! I've used StringReplace ,_ReplaceStringInFile, StringRegExpReplace, all the same very slow,. The number of replacements in the file about 8000 Any help would be greatly appreciated #include <File.au3> $path = @ScriptDir & '\xmlfo.xml' $OXML = FileOpen($path, 256) $XML = FileRead($OXML) $term = 'post' $nofr = 1 Local $aArray = StringRegExp($XML, '(?s)<entry[^>]*>.*?</entry>', 3) FileClose($OXML) $XL = $XML If Not @error Then For $i = 0 To UBound($aArray) - 1 ;get data start ;ConsoleWrite ( $aArray[0] &' '&$i& @CRLF) $date = StringRegExp($aArray[$i], '(?i)<published>(.*?)</published>', 3) If @error Then $date = StringRegExp("date err", "(.{33,}?(?:\s)|.+)", 3) ElseIf Not @error Then ;ConsoleWrite($date[0] & ' ' & $i & @CRLF) EndIf $kind = StringRegExp($aArray[$i], '(?i)<category>(.*?)</category>', 3) If @error Then $kind = StringRegExp("kind err", "(.{33,}?(?:\s)|.+)", 3) ;ConsoleWrite ( $kind[0] &' '&$i& @CRLF) ElseIf Not @error Then ;ConsoleWrite ( $kind[0] &' '&$i& @CRLF) EndIf If $kind[0] = $term And Data(getdate($date[0], 'year'), getdate($date[0], 'month')) = True Then _ReplaceStringInFile($path, $aArray[$i], '') If Not @error Then ;MsgBox(16,'',$XL) ConsoleWrite($nofr & ' ' & $i & @CRLF) $nofr = $nofr + 1 EndIf ;FileDelete(@ScriptDir & '\XML_output.xml') ;FileWrite (@ScriptDir & '\XML_output.xml', StringToBinary ( StringReplace($temp, $aArray[$i], "") , 4) ) Else ConsoleWrite ('err0x0'& @CRLF) EndIf Next EndIf
  9. Regular expressions, I hate them, seriously I have a MAC address in this format: "A2B3B56B7C3A" And I would like to change it in: "A2-B3-B5-6B-7C-3A" The MAC address can be a little longer than that one, but we are sure that the total digit number is an even number. I've tried a lot of patterns but I have not tried the right one. This is the closest one I've tried but the output shows a final hyphen (I could cut it through StringTrimLeft but I would like to do it using just RegEx). ConsoleWrite(StringRegExpReplace("A2B3B56B7C3A", "(.{2})", "$1-")) I don't understand why this pattern doesn't work ConsoleWrite(StringRegExpReplace("A2B3B56B7C3A", "^(?:.{2})(.{2})+?", "-$1")) Thanks in advance
  10. I’m a complete newbie when it comes to using StringRegExp. Although I’ve successfully modified a couple of patterns in existing scripts, I’ve never been sure where to start in formulating a new pattern. Thus, I’ve avoided using them. But now I need to. The string I’d like to recognize and replace is of the form: prekeykey<any characters>post To put it in words, I’m looking for any occurrence of two or more consecutive key strings that are embraced by pre and post strings, regardless of any follow-on characters. The slash characters are part of the individual elements, but could possibly occur on their own. (What makes this doubly confusing is that the slash character is an element of the RegExp syntax.) Examples of strings to be recognized and replaced: prekeykeykeykey post prekeykeykeykeyabcdpost prekeykeypost But neither of the following should be “found”, since the have only one key: prekeypost prekeyabcdpost If someone versed in RegExp’s would be so kind as to provide me with a nudge in the form of a suitable pattern, I might be able to make my way further along the path toward a working knowledge of these things. So far, I’ve looked at 100 examples and can’t get a toehold. Detecting "two consecutive" appears to be a rare requirement. Thanks in advance for any help.
  11. I often copy text from a website or pdf into a variable and once in a while pasting it back into WordPad gives weird results. It used to originate more frequently within larger Facebook texts or YouTube comments. One example from a pdf is where bullets were changed into a corner like character, etc. I assume many of these could be control characters? What is the best way to filter them out, please? From reading in the manual, my only guess was something like the following, but it seems to do nothing (not sure though, and less easy to test for me...). $text = StringRegExpReplace ( $text, '[[:cntrl:]]', "" ) Or is it something with [:print:] ? (meaning, "give me only the characters that would normally print?") I don't mind if your solution removes Returns too (though ideally not), cause I usually remove those myself. Thank You for any pointers!
  12. For my application, I have one string that may contain as item pointers a "space + single character/number + )" For example: Some text. 1) blah 2) blah a) yes b) no. I'd like this to become: Some text. (1) blah (2) blah (a) yes (b) no. It seems I understand the use of the back reference $1, but I may not be grasping the functionality of non-capturing groups... I hoped I could use the latter functionality so in the MAIN CODE I would not get the space between '(' and $1 The first code line below now giving me: Some text. ( 1) blah ( 2) blah ( a) yes ( b) no. Local $sOutput = StringRegExpReplace($sInput, '((?:\s).\))', ' ($1' ) As another trial, this doesn't seem to work either: Local $sOutput = StringRegExpReplace($sInput, '(\s.\))', ' (' & StringRight('$1', 2) ) MAIN CODE: Test() Func Test() Local $sInput = 'Some text. 1) blah 2) blah a) yes b) no.' ; look for 'space + any char + )' and put '(' in front Local $sOutput = StringRegExpReplace($sInput, '( (?:\s).\) )' , ' ($1' ) Display($sInput, $sOutput) EndFunc ;==>Test Func Display($sInput, $sOutput) ; Format the output. Local $sMsg = StringFormat("Input:\t%s\n\nOutput:\t%s", $sInput, $sOutput) MsgBox(0, "Results", $sMsg) EndFunc ;==>Display Thank you for any pointers
  13. I would like to replace the percentage of width div.gallery { float: left; width:20%; } I tried... $colread = "10%" $replace = StringRegExpReplace($colcss,'([0-9][^;])',$colread) This mode does not work well, can you help me to intercept the exact text between width:????????; Thanks guys
  14. Morning It's 5:30 AM and been sitting here staring at the help file but it looks like an alien language to me. I have the following example strings [8]Bird [9]Cat [10]Dog What I want is Bird Cat Dog Now a easy solution would be to just trim it to the left by 3, however there are cases when it could be 4 (example Dog being [10]), so I figured StringRegExpReplace() is what I am going to have to use unless there is a easier/better method. I don't know how or where to start though StringRegExpReplace($String, "[*]", "") Thanks
  15. Hi all i have a big amount of text files that is link this i want it to cut each part alone and the separator is bracket then number then bracket {NUM} so the first one must be i tried this #include <Array.au3> $sString=ClipGet() $sResult=StringRegExpReplace($sString,"(\{\d{1,}\})",@CR & "$1") $sResult=StringRegExpReplace($sResult,"(\r)(.*)","$2",1) ;If you want it in an array add this: $array=StringSplit($sResult,@CR) $var = 1 For $i = 1 To $array[0] FileWrite(@DesktopDir & "\sura\" & $var & ".txt" , $array[$i] & @CRLF) $var = $var + 1 Next it is cutting the text when it see the {NUM} but it is also cutting it when it see a new line i want it to complete the sentence even if it is on 2 lines any ideas ?
  16. Is it possible to left pad a matched group? Here is my situation. I am working on a program to integrate inventory from my companies warehouse with our website. Our part numbers in our Warehouse inventory look like this: 1501895, 1000973, 5000165, 6000002, etc. On our website, these same numbers would look like this: 15-1895, 1-973,5-165, 6-02 My program monitors our warehouse inventory database for changes, and when a change is made it needs to find the matching item on our website. This is the code that I originally used: StringRegExpReplace($new_items[$i][0],"([1-9]{1,2})(0*)(\d{1,4})","$1-$3") However I noticed this does not work for numbers that match my last example. The last matched group needs to be zero padded if the number is less than 10. Does anyone have an idea of where to start for this? Is there a better way than how I have started?
  17. Hi all I get a problem with StringRegExpReplace Here is the code: $string = "< / li > < / li > < /li > < / li> < / li > </ li >" $array = StringRegExp($string, "<(.*)/(.*)(li)(.*)>", 3) _ArrayDisplay($array) I want to replace all with </li>, and the final result is: </li> </li> </li> </li> </li> </li> Please help, thanks
  18. Hello, extract text from an HTML for extracting text. Now I want to remove all html codes between < and > symbols. try to use, without success, stringRegExpReplace : $mytext = stringRegExpReplace($mytext, "\<(.*)\>", "") post here an input example <DIV style="position:absolute;top:459;left:63"><nobr><span class="miostile"><b>di ciccio formaggio</b></span></nobr></DIV> <DIV style="position:absolute;top:475;left:63"><nobr><span class="miostile"> PAVIA</span></nobr></DIV> <DIV style="position:absolute;top:499;left:63"><nobr><span class="miostile">Arrestati con la droga al bar<br>Minerva. Tre sudamericani<br>sono stati bloccati con un et-<br>to di «fumo» e con 15 grammi<br>di cocaina. La droga, secondo<br>gli investigatori, era pronta<br>ad essere spacciata. L'arresto<br>è stato movimentato con tan-<br>to di bicchieri rotti e sedie ro-<br> and output i want to obtain: di ciccio formaggio PAVIA Arrestati con la droga al barMinerva. Tre sudamericani<br>sono stati bloccati con un et-to di «fumo» e con 15 grammidi cocaina. La droga, secondogli investigatori, era prontaad essere spacciata. L'arrestoè stato movimentato con tan-to di bicchieri rotti e sedie ro- thank you for any help, m.
  19. 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
  20. Hi there, i actualley try a quiet simple thing. From a given path like "c:\temp\test.doc" i like to extract only the File BaseName "test" without the extension. I there an Macro i can use. I found StringRegExpReplace(). Pherhaps you know how to use it. i tried this so far: $filebasename = StringRegExpReplace($sFile, '^.*\\', '') $filebasename = StringRegExpReplace($Font, '\.[^.]*\Z', '') This seems to work. is there an easier way ??