GMK Posted December 20, 2012 Share Posted December 20, 2012 (edited) $s = "?t1=toto&t2=titi&t3=tyty&t4=tutu" ConsoleWrite($s & " --> ") ;if I want to remove t1, t3 & t4 the result will be : ;?t2=titi ;note that the "?" need to stay, whereas the "&" needs to be removed. $s = StringRegExpReplace($s, "(&?t[^2]=w*&?)", "") ConsoleWrite($s & @CRLF) Edited December 20, 2012 by GMK Link to comment Share on other sites More sharing options...
FireFox Posted December 20, 2012 Share Posted December 20, 2012 @GMKThanks, the tnumber= was just an example. But I will be able to edit the pattern to do what I want.Br, FireFox. Link to comment Share on other sites More sharing options...
FireFox Posted December 21, 2012 Share Posted December 21, 2012 (edited) One last thing, the ampersand of the param is deleted including the next one. e.g : $s = "?t1=toto&t2=titi&t3=tyty&t4=tutu" $s = StringRegExpReplace($s, "(&?t[2|3]=w*&?)", "") ;will output "?t1=totot4=tutu" instead of "?t1=totot&t4=tutu" Thanks for anyhelp. Edited December 21, 2012 by FireFox Link to comment Share on other sites More sharing options...
PhoenixXL Posted December 21, 2012 Author Share Posted December 21, 2012 (edited) Please mention the keypoints very clearly$s = "?t1=toto&t2=titi&t3=tyty&t4=tutu" $s = StringRegExpReplace($s, "(t[13]=\w*&?)", "") ;"?t1=totot&t4=tutu" ;will output "?t1=totot4=tutu" instead of "?t1=totot&t4=tutu" ;Strip Ending ampersand [comes across when for example 2 and 4 is deleted] $s = StringRegExpReplace ( $s, '(?m)&(r|n|$)' , '' ) ConsoleWrite($s & @CR) Edited December 21, 2012 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
FireFox Posted December 21, 2012 Share Posted December 21, 2012 (edited) Please mention the keypoints very clearly Sorry, but actually it's what I wanted. Thanks! I'm now trying to match the value of a parameter, but it can end by a new line (so I won't use the _StringBetween func) I have tried many things without success, here what I have for the moment : $s = "?t1=toto&t2=titi&t3=tyty&t4=tutu" $s = StringRegExp($s, "(&?(t2)=w*&??)", 1) ConsoleWrite($s[0] & @CR) ;output: &t2=titi As you can see the parameter &t2 is still there and I would like to remove it. Thanks for anyhelp. Br, FireFox. Edited December 21, 2012 by FireFox Link to comment Share on other sites More sharing options...
jdelaney Posted December 21, 2012 Share Posted December 21, 2012 (edited) If you already split the params, why not logically concatenate them back together? Edited December 21, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
FireFox Posted December 21, 2012 Share Posted December 21, 2012 If you already split the params, why not logically concatenate them back together?Of course I would be able to do it with String* functions, but I will take more lines. Link to comment Share on other sites More sharing options...
PhoenixXL Posted December 21, 2012 Author Share Posted December 21, 2012 (edited) Example#include <Array.au3> $s = "?t1=toto&t2=titi&t3=tyty&t4=tutu" $s = StringRegExp($s, "(?:t[13]=)(\w*&?)", 3) If Not IsArray($s) Then Exit -1 ;The value of the first and third is displayed in this example ;Strip Ending ampersand [comes across when for example 2 and 4 is deleted] For $i = 0 To UBound($s) - 1 $s[$i] = StringRegExpReplace($s[$i], '(?m)(&)(r|n|$)', '\2') Next _ArrayDisplay( $s )Thumbs up if it helps Edited December 21, 2012 by PhoenixXL FireFox 1 My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
FireFox Posted December 21, 2012 Share Posted December 21, 2012 Thumbs up if it helps Yes thanks! I really want to understand regexp but there is plenty of possibilities that I fail everytime Link to comment Share on other sites More sharing options...
PhoenixXL Posted December 21, 2012 Author Share Posted December 21, 2012 (edited) This one is Pure RegEx without Replacements#include <Array.au3> $s = "?t1=toto&t2=titi&t3=tyty&t4=tutu" $s = StringRegExp($s, "(?:t[13]=)(\w*)(?:&|)", 3) If Not IsArray($s) Then Exit -1 ;The value of the first and third is displayed in this example _ArrayDisplay( $s ) Edited December 21, 2012 by PhoenixXL FireFox 1 My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
PhoenixXL Posted December 22, 2012 Author Share Posted December 22, 2012 Help;Note that special characters do not retain their special meanings inside a set, ;with the exception of \\, \^, \-,\[ and \] match the escaped character inside a set. MsgBox ( 0 , 0 , Test ( 'a' & @CRLF & 'b' ) ) Func Test($sString ) ;How come CRLF are replaced ??? Return StringRegExpReplace( $sString, '[\r\n]', '') EndFunc My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 22, 2012 Moderators Share Posted December 22, 2012 PhoenixXL,Why do you expect @CRLF not to be replaced? You are asking for any @CR or @LF to be removed - @CRLF is just the 2 one ofter the other.Or is it the that is confusing you? As "r" and "n" are not "special characters" the "#" retains its meaning within the set.Does that help? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
PhoenixXL Posted December 22, 2012 Author Share Posted December 22, 2012 (edited) Note that special characters do not retain their special meanings inside a setThis statement confused me thanks got it clear now Edited December 22, 2012 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
PhoenixXL Posted December 22, 2012 Author Share Posted December 22, 2012 (edited) Simple But yet Confusing Need Help[solved]; Aim....: To delete every single vowel in a word ; - Exception : if the first and last alphabets are vowel ignore them Local $sString = 'rejuvenation' Local $sPattern = '(?i)([^aeiou])' & _ ; (First Group) Match the starting of the Word with a Non-Vowel. '([aeiou])([^aeiou])' ; (Second group) Matching the Vowel and the following single Non-Vowel. Local $aRegEx = '' ;Set Extended for the Initiation SetExtended(1) While @extended $aRegEx = StringRegExpReplace($sString, $sPattern, '\1\3', 1) ;Assign the New String $sString = $aRegEx WEnd MsgBox ( 64, 'Return', $aRegEx ) Edited December 23, 2012 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
jchd Posted December 22, 2012 Share Posted December 22, 2012 Regarding the post about rn inside character class, you might have confused with R which, as the doc says, does not retain its special meaning. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
PhoenixXL Posted January 20, 2013 Author Share Posted January 20, 2013 R which, as the doc says, does not retain its special meaning.Which doc are you referring to ? My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
guinness Posted January 20, 2013 Share Posted January 20, 2013 Well the help file doesn't mention this. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jchd Posted January 20, 2013 Share Posted January 20, 2013 I always mean the official documentation found on the PCRE site. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
guinness Posted January 20, 2013 Share Posted January 20, 2013 I should really compare the two and see what is missing. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
FireFox Posted March 14, 2013 Share Posted March 14, 2013 (edited) Hi, I'm stuck with a simple regexp, however it does not work. I have an url, and I want to extract the file name from it, so it will strip the caracters until the last slash and will stop from that until a query "?" or a fragment "#" This is what I've done so far : Local $s = "", $a = 0 $s = "http://www.example.com/path/?toto#fragment" ;~ $a = StringRegExp($s, "/([^/]*$)", 1) ;1st part, works ;~ $a = StringRegExp($s, "(.*?)[#|\?]", 1) ;2nd part, works $a = StringRegExp($s, "/([^/]*$)[#|\?]", 1) ;both: does not work. ConsoleWrite($a[0] & @crlf) Thanks for anyhelp. Br, FireFox. Edited March 14, 2013 by FireFox Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now