by Richie88 at 2013-02-13 20:31:50
Hey Guys,by Richie88 at 2013-02-13 23:08:58
Just trying to get a regex code to remove a path, I’m building csv files but when a new file is created for some reason it is appending the path/file name to the front of it and causing problems.
Can’t for the life of me work out as to why, so what I’d like to do is simlpy remove the path via a regex code?
The path is always the same (For now)C:\DropBox\Data Loader\CA no PL\FV.csv @{Cust Id=2212; Store=; First Name=dddd; Last Name=dsss; Follow Up=11/19/2012; Address=Street;
Suburb=ALDERLEY; State=QLD; Post
May occur a few times (If theres 2 new files created)
Once the file is created there is no problem, I could create them all then re-run the script, but i need it so other people can run it in future!
Cheers
Ended up getting it cheersby mjolinor at 2013-02-14 03:53:43
Always the way after you post something…
Any help?by MattG at 2013-02-14 18:08:21$test = 'C:\DropBox\Data Loader\CA no PL\FV.csv @{Cust Id=2212; Store=
; First Name=dddd; Last Name=dsss; Follow Up=11/19/2012; Address=Street; Suburb=ALDERLEY; State=QLD; Post'
$test -replace '^.+(@{.+)$','$1'
@{Cust Id=2212; Store=; First Name=dddd; Last Name=dsss; Follow Up=11/19/2012; Address=Street; Suburb=ALDERLEY; State=QLD; Post
Eww. Ugly string. I won’t ask why you need to work with a string in that form. ;D Anyway, I would avoid regexes altogether in a simple case like this. I did the following:$test = 'C:\DropBox\Data Loader\CA no PL\FV.csv @{Cust Id=2212; Store=
; First Name=dddd; Last Name=dsss; Follow Up=11/19/2012; Address=Street; Suburb=ALDERLEY; State=QLD; Post'
"@$($test.Split('@')[1])"