Regex issue please help
Regex issue please help
How do add a page address to all numbers?
-123456_12345
-19,876
12345_98
123456
Replace with:
site.com/-123456_12345
site.com/-19876
site.com/12345_098
site.com/123456
I have a huge list and I do not know how to do it?
This is very important for me!!!
-123456_12345
-19,876
12345_98
123456
Replace with:
site.com/-123456_12345
site.com/-19876
site.com/12345_098
site.com/123456
I have a huge list and I do not know how to do it?
This is very important for me!!!
Re: Regex issue please help
Is your input like
INPUT1.txt
or like:
INPUT2.txt
?
If INPUT1.txt and just a couple of hundreds/thousands of lines, enter this on a CMD prompt:
If like INIPUT2 and/or 10000+ lines, execute this command:
I have SSED on my systems for years; can't find where I downloaded it. If you have trouble finding it, let me know.
But I think any other SED utility will do (this is a basic SED command)
EDIT: Found it: http://sed.sourceforge.net/grabbag/ssed/
INPUT1.txt
Code: Select all
-123456_12345
-19,876
12345_98
123456
INPUT2.txt
Code: Select all
bla-123456_12345foo
bla-19,876foo
bla12345_98foo
bla123456foo
If INPUT1.txt and just a couple of hundreds/thousands of lines, enter this on a CMD prompt:
Code: Select all
(for /f "delims=" %x in (INPUT1.txt) do @echo site.com/%x) > OUTPUT.txt
Code: Select all
SSED.exe s/\([-0-9_,]*\)/site.com\/\1/ INPUT1.txt > OUTPUT.txt
But I think any other SED utility will do (this is a basic SED command)
EDIT: Found it: http://sed.sourceforge.net/grabbag/ssed/
Re: Regex issue please help
Where to put a text file - input (what kind of path)?
I want to put any address at the beginning of each line:
https://website/album-XXX_XXX
https://website/albums-XXX
https://website/wall-XXX
https://website/albumsXXX
XXX <== ALWAYS NUMBER
always name:
albums
albums-
album
wall-
I want to put any address at the beginning of each line:
https://website/album-XXX_XXX
https://website/albums-XXX
https://website/wall-XXX
https://website/albumsXXX
XXX <== ALWAYS NUMBER
always name:
albums
albums-
album
wall-
Re: Regex issue please help
- Just put the file with the numbers in a folder, let's say C:\MyTestDebugger wrote:Where to put a text file - input (what kind of path)?
- Copy SSED.exe also to this folder
- Start CMD.exe
- execute this command to go to the MyTest folder: CD /D C:\MyTest
- type one of the commands mentioned in the previous post.
When you see the prompt again, the command has finished
Your output is in OUTPUT.txt (in that same folder)
Re: Regex issue please help
Not work for me:
C:\Windows\system32>SSED.exe s/\([-0-9_]*\)/site.com\/\1/ CD /D E:\My Test.txt > OUTPUT.txt
SSED.exe: can't read CD: No such file or directory
SSED.exe: can't read /D: No such file or directory
SSED.exe: can't read E:\My: No such file or directory
SSED.exe: can't read Test.txt: No such file or directory
What am I doing wrong? The path exists.
E:\My test\my test.txt
example PATH
Q:/Rysunki ALL!!/http://site.com/album-47_22995651,,,21,7 KB,,,05-05-14 05:34:26,,
Example add:
http://site.com/album
C:\Windows\system32>SSED.exe s/\([-0-9_]*\)/site.com\/\1/ CD /D E:\My Test.txt > OUTPUT.txt
SSED.exe: can't read CD: No such file or directory
SSED.exe: can't read /D: No such file or directory
SSED.exe: can't read E:\My: No such file or directory
SSED.exe: can't read Test.txt: No such file or directory
What am I doing wrong? The path exists.
E:\My test\my test.txt
example PATH
Q:/Rysunki ALL!!/http://site.com/album-47_22995651,,,21,7 KB,,,05-05-14 05:34:26,,
Example add:
http://site.com/album
Re: Regex issue please help
Another approach:
Use MS-Word Search and Replace.
π is a paragraph sign.
Enable view hidden (Ctrl+Shift+8) and you will see
-123456_12345π
-19,876π
12345_98π
123456π
π = ^p in the Search&Replace dialog-box.
So, in your case you need to search for π:
^p
and Replace with:
^psite.com/
No regex skills needed.
I don't think this is possible with notepad.
with Notepad++ ?
Use MS-Word Search and Replace.
π is a paragraph sign.
Enable view hidden (Ctrl+Shift+8) and you will see
-123456_12345π
-19,876π
12345_98π
123456π
π = ^p in the Search&Replace dialog-box.
So, in your case you need to search for π:
^p
and Replace with:
^psite.com/
No regex skills needed.
I don't think this is possible with notepad.
with Notepad++ ?
Re: Regex issue please help
I have no idea how you got from these instructions:Debugger wrote: What am I doing wrong?
(Where command = SSED.exe s/\([-0-9_,]*\)/site.com\/\1/ INPUT1.txt > OUTPUT.txt )- Just put the file with the numbers in a folder, let's say C:\MyTest
- Copy SSED.exe also to this folder
- Start CMD.exe
- execute this command to go to the MyTest folder: CD /D C:\MyTest
- type one of the commands mentioned in the previous post.
When you see the prompt again, the command has finished
Your output is in OUTPUT.txt (in that same folder)
To this:
But you need to enclose filenames/folders with spaces in them in "", like "E:\My Path\My file.txt"Debugger wrote: C:\Windows\system32>SSED.exe s/\([-0-9_]*\)/site.com\/\1/ CD /D E:\My Test.txt > OUTPUT.txt
Re: Regex issue please help
(I really confused about what the source files look like & just what we're trying to end up with?)
Re: Regex issue please help
That's how these threads go in general: original question is about something relatively straightforward, only to end up with a qustion that is only remotely related to the original one.therube wrote:(I really confused about what the source files look like & just what we're trying to end up with?)
We'll get to that point eventually. Patience, my friend, patience ...
To speed things up :
@Debugger, can you post 10 lines of your original input file? And what should the exact output be for those lines?
Re: Regex issue please help
I think it's natural, like in the real world.That's how these threads go in general: original question is about something relatively straightforward, only to end up with a qustion that is only remotely related to the original one.
We'll get to that point eventually. Patience, my friend, patience ...
But you can try next time to make this
the 2nd post.To speed things up :
@Debugger, can you post 10 lines of your original input file? And what should the exact output be for those lines?
Re: Regex issue please help
I do not have a problem with how things 'flow'. On the contrary: after the first step/suggestion, other people can jump in and take that to the next level (or suggest a diffrent approach, like you did)Stamimail wrote:I think it's natural, like in the real world.That's how these threads go in general: original question is about something relatively straightforward, only to end up with a qustion that is only remotely related to the original one.
We'll get to that point eventually. Patience, my friend, patience ...
But you can try next time to make thisthe 2nd post.To speed things up :
@Debugger, can you post 10 lines of your original input file? And what should the exact output be for those lines?
That is what a forum is about (IMO): sharing solutions/knowledge that also helps other people beside the one that asked the question.
Downside is that you have to re-think and rewrite multiple times.
I'll try your approach a next time. Maybe it *does* work better.
Re: Regex issue please help
Y:/ZK 1 Drawings2 /-40010106_187898190,,,72 KB,,,26-03-15 23:58:44,,
Y:/ZK Drawings/-40010106_187898190,,,170 KB,,,26-03-15 23:58:42,,
Z:/ZK 1/-40010106_187898190,,,168 KB,,,26-03-15 23:58:43,,
Replace with:
Y:/ZK 1 Drawings2/http://site.com/album-40010106_187898190,,,72 KB,,,26-03-15 23:58:44,,
Y:/ZK Drawings/http://site.com/album-40010106_187898190,,,170 KB,,,26-03-15 23:58:42,,
Z:/ZK 1/http://site.com/album10106_187898190,,,168 KB,,,26-03-15 23:58:43,,
Drive Letter + Folder + HTTP + other name
U:\PATH.csv
Y:/ZK Drawings/-40010106_187898190,,,170 KB,,,26-03-15 23:58:42,,
Z:/ZK 1/-40010106_187898190,,,168 KB,,,26-03-15 23:58:43,,
Replace with:
Y:/ZK 1 Drawings2/http://site.com/album-40010106_187898190,,,72 KB,,,26-03-15 23:58:44,,
Y:/ZK Drawings/http://site.com/album-40010106_187898190,,,170 KB,,,26-03-15 23:58:42,,
Z:/ZK 1/http://site.com/album10106_187898190,,,168 KB,,,26-03-15 23:58:43,,
Drive Letter + Folder + HTTP + other name
U:\PATH.csv
Re: Regex issue please help
The easiest way to replace would be a regular expression, in a powerful word editor, the performance for a million paths would be the fastest.
Y:/ANYFOLDERNAME/SUBFOLDER NAME,,,210 KB,,,26-03-15 23:58:41,,
Replace with:
Y:/ANYFOLDERNAME/https://site.com/album- OR albumSUBFOLDERNAME,,,210 KB,,,26-03-15 23:58:41,,
Just how to add a url between the folder name and the subfolder?
Y:/ANYFOLDERNAME/SUBFOLDER NAME,,,210 KB,,,26-03-15 23:58:41,,
Replace with:
Y:/ANYFOLDERNAME/https://site.com/album- OR albumSUBFOLDERNAME,,,210 KB,,,26-03-15 23:58:41,,
Just how to add a url between the folder name and the subfolder?
Re: Regex issue please help
First up, some remarks:Debugger wrote:Y:/ZK 1 Drawings2 /-40010106_187898190,,,72 KB,,,26-03-15 23:58:44,,
Y:/ZK Drawings/-40010106_187898190,,,170 KB,,,26-03-15 23:58:42,,
Z:/ZK 1/-40010106_187898190,,,168 KB,,,26-03-15 23:58:43,,
Replace with:
Y:/ZK 1 Drawings2/http://site.com/album-40010106_187898190,,,72 KB,,,26-03-15 23:58:44,,
Y:/ZK Drawings/http://site.com/album-40010106_187898190,,,170 KB,,,26-03-15 23:58:42,,
Z:/ZK 1/http://site.com/album10106_187898190,,,168 KB,,,26-03-15 23:58:43,,
Regex is all about pattern. So the more examples, the better.
And it's also about precision:Y:/ZK 1 Drawings2 /-40010106_1.... A foldername ending in a space? And that space is gone in the converted list?
But if I have to do with those 3 lines (which will probably go wrong, as an example in your opoeningpost included a "," and that is used here as a separator/delimiter)
Anyhow ... Based on your 3 examples:
- Put SSED.exe in some folder
- Save the script as AddURL.cmd in that same folder
- Drag your inputfile to the AddURL.cmd script
- If your inputfile was Q:\path\filename.ext, the output will be in Q:\path\filename_out.ext
- Done
Code: Select all
@"%~dp0\SSED.exe" s/\/\([-0-9_]*,\)/\/http:\/\/site.com\/album\1/ %1 > "%~dpn1_out.%~x1"
How do you know that?Debugger wrote:The easiest way to replace would be a regular expression, in a powerful word editor, the performance for a million paths would be the fastest.
Re: Regex issue please help
It does not end with a space.
It still does not work, the output file is empty.
Just add a website url to each subfolder's name. It can not be explained any better
It still does not work, the output file is empty.
Just add a website url to each subfolder's name. It can not be explained any better
Re: Regex issue please help
There is a space between Drawings2 and /. Don't you see it?Debugger wrote:It does not end with a space.
As you managed before to completely screw up some pretty straightforward instructions, I can only assume you did the same with the current - even simpler- steps.It still does not work, the output file is empty.
Let me repeat them:
- Put SSED.exe in some folder
- Save the script as AddURL.cmd in that same folder
- Drag your inputfile to the AddURL.cmd script
- If your inputfile was Q:\path\filename.ext, the output will be in Q:\path\filename_out.ext
- Done
- Put SSED.exe in some folder
- Save the script as AddURL.cmd in that same folder
SSED.exe and AddURL.cmd have to be in the same folder.
(Just don't think that it will do when SSED.exe is in your PATH somewhere ...)
Re: Regex issue please help
I think I'm doing what you say, but it does not work for me. No positive results.
With regex it would be a thousand times faster, but I do not remember the regex that I got a few years ago from a friend.
https://s15.postimg.cc/c2fjka8nv/Screen ... .58_AM.jpg
There are no spaces at the end, bad copy/paste.
Edit:
In addition, the change must still be taken into account:
album-(\d+)_(\d+)
album(\d+)_(\d+)
tag(\d+)
wall-(\d+)
With regex it would be a thousand times faster, but I do not remember the regex that I got a few years ago from a friend.
https://s15.postimg.cc/c2fjka8nv/Screen ... .58_AM.jpg
There are no spaces at the end, bad copy/paste.
Edit:
In addition, the change must still be taken into account:
album-(\d+)_(\d+)
album(\d+)_(\d+)
tag(\d+)
wall-(\d+)
Re: Regex issue please help
This *IS* all regex ... SED is a texteditor that uses regex pattern to search for text and replace it with something else.Debugger wrote: With regex it would be a thousand times faster, but I do not remember the regex that I got a few years ago from a friend.
It is one of the fastest ways to do what you want (if not THE fastest)
Alright then, Let's try it another way:I think I'm doing what you say, but it does not work for me. No positive results.
- Extract the attached AddURL.zip to some empty folder
- In File Explorer, Drag&drop input1.txt to AddURL.cmd
BTW: content of input1.txt:A CMD window will open.Code: Select all
Y:/ZK 1 Drawings2/-40010106_187898190,,,72 KB,,,26-03-15 23:58:44,, Y:/ZK Drawings/-40010106_187898190,,,170 KB,,,26-03-15 23:58:42,, Z:/ZK 1/-40010106_187898190,,,168 KB,,,26-03-15 23:58:43,,
- Please post the content of that window
- Press the spacebar to close that CMD window
- Is there a input1_out.txt in the folder?
- What are the contents of that file?
I'll ignore those for now as they were not in your original 10 examples.In addition, the change must still be taken into account:
album-(\d+)_(\d+)
album(\d+)_(\d+)
tag(\d+)
wall-(\d+)
Please create examples in such a way that if those get converted the right way, all others will go well too.
(again: exact input; exact output)
In the meantime I have build a better regex-"query". But if that can be used depnds on your definitive list of examples.
- Attachments
-
- AddURL.zip
- (42.94 KiB) Downloaded 273 times
Re: Regex issue please help
Your executable file does not work, it shows 1KB of data (empty)
Re: Regex issue please help
As a test, I downloaded the zip myself: SSED.exe is OK.Debugger wrote:Your executable file does not work, it shows 1KB of data (empty)
Sometimes virusscanners quarantine a suspicious file, while replacing it with a placeholder text-file with some explanation (what happens when you open the 1Kb SSED.exe in notepad?)
As an alernative, you can replace the 1KB exe with the one you already downloaded and run the tests that way.
Re: Regex issue please help
I have tested it many times, it does not work, I need a log file that analyzes what exactly happens. How to create a log file?
Re: Regex issue please help
Shows only this, nothing more, from empty.
Re: Regex issue please help
I think regex, it would be better, speeds up millions of lines in a text editor (Acceleration)
Drive Letter:\FOLDER\SUBFOLDER\.....
Replace with:
Drive Letter:\FOLDERhttp://site.com/.....
But not work for me. All wrong regex!!!
[E-Z]:\\[A-Za-z0-9_-Unicode Russian]\(\d+_\d+) and OTHER
Replace with:
[E-Z]:\\[A-Za-z0-9_-Unicode Russian]\(\d+_\d+) AND OTHER$2
Very Complex Regex!!!
you can change all character "\" to site.com/XXX and other but it will cause even more damage to the text
Drive Letter:\FOLDER\SUBFOLDER\.....
Replace with:
Drive Letter:\FOLDERhttp://site.com/.....
But not work for me. All wrong regex!!!
[E-Z]:\\[A-Za-z0-9_-Unicode Russian]\(\d+_\d+) and OTHER
Replace with:
[E-Z]:\\[A-Za-z0-9_-Unicode Russian]\(\d+_\d+) AND OTHER$2
Very Complex Regex!!!
you can change all character "\" to site.com/XXX and other but it will cause even more damage to the text
Re: Regex issue please help
How to remove any character in a text file, in lines, leaving only the letter of the disk and the name of the folder and subfolder, and only the folder itself???