ChrisL Posted February 10, 2021 Share Posted February 10, 2021 $Str1 = "/photo-selection/my-albums/1104042" $Str2 = "/photo-selection/my-albums/shared-982502" $regEx = "albums/(?:shared-)(\d+$)" MsgBox(0,"",StringRegExpReplace($Str1,$RegEx,"albums/")) MsgBox(0,"",StringRegExpReplace($Str2,$RegEx,"albums/")) Can someone help with this, I need 1 RegEx to work with both strings, sometimes it contains "shared-" and sometimes not, I know there are other ways to do it but I think it should be possible to do with just StringRegExp Thanks [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
ChrisL Posted February 10, 2021 Author Share Posted February 10, 2021 Typical as soon as I click post I get it... $regEx = "albums/(?:shared-)?(\d+$)" missing a ? after :shared-)? [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
jguinch Posted February 10, 2021 Share Posted February 10, 2021 what do you want to replace, by what ? Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
ChrisL Posted February 10, 2021 Author Share Posted February 10, 2021 I was getting rid of the "random number" or "shared-random number" [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
jguinch Posted February 10, 2021 Share Posted February 10, 2021 $regEx = "(?:shared-)?\d+$" Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
ChrisL Posted February 11, 2021 Author Share Posted February 11, 2021 Thanks! [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
rudi Posted February 11, 2021 Share Posted February 11, 2021 Hi. if I get your task description right you basically need to cut off everything following the final "/" in your strings? $Str1 = "/photo-selection/my-albums/1104042" $Str2 = "/photo-selection/my-albums/shared-982502" MsgBox(0, 'String Left String 1', StringLeft($Str1,StringInStr($Str1,"/",0,-1))) ; take the left part of any string including the last occurence of "/" MsgBox(0, 'String Left String 2', StringLeft($Str2,StringInStr($Str2,"/",0,-1))) ; take the left part of any string including the last occurence of "/" $RegEx="^(.*?/)(?:[^/]+)$" MsgBox(0, 'RegEx String 1', StringRegExpReplace($Str1,$RegEx,"$1")) MsgBox(0, 'RegEx String 2', StringRegExpReplace($Str2,$RegEx,"$1")) Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
mikell Posted February 11, 2021 Share Posted February 11, 2021 @rudi cut off everything following the final "/" = StringRegExpReplace($Str1, '[^/]+$', "") Link to comment Share on other sites More sharing options...
ChrisL Posted February 12, 2021 Author Share Posted February 12, 2021 No I can't do that because sometimes it maybe a completely different string, which is why I included the albums/ as part of the search term, sometimes it has shared- and sometimes it doesn't. So basically if it doesn't contain /albums then leave it, if it contains album/shared-xxxxxxx then trim it, if it contains albums/xxxxxxx then trim it [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
mikell Posted February 12, 2021 Share Posted February 12, 2021 1 hour ago, ChrisL said: if it doesn't contain /albums then leave it, if it contains album/shared-xxxxxxx then trim it, if it contains albums/xxxxxxx then trim it Ah sorry, I misunderstood Something like this then ? StringRegExpReplace($Str1, 'albums/\K[^/]+$', "") Link to comment Share on other sites More sharing options...
ChrisL Posted February 12, 2021 Author Share Posted February 12, 2021 Thank you I will give that a try [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire 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