|
A regular expression to match the seconds is trivial: m\d+s .
The problem is that a regular expression works on a single string. There is no way for a pure regex solution to group the files by the start of the name and then apply a sequential number, because the regex only sees one filename at a time, and doesn't maintain any state between invocations.
If you want to do this in code, it should be fairly easy, but you'd need to specify which language you were using.
If you want to use a renamer tool, you'll need to consult the documentation to see if it can do this sort of thing, and if so, how.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard, very sorry for late reply. I'm on a new browser and forgot to put in new bookmark folder for my posts!
Richard, my renamer is good at handling renaming files, it's just the regex part that I dont' know how to deal with. The renamer is fantastic but in one of my crashes, I lost years worth or regex naming files all in one backup file. It was a great loss. And it handled all sorts of difficult things like this. But the renamer's forum is gone so no going back to my posts there to try to rebuild.
All that's needed is the before and after, as it were. How to go from scenarios like this within the file name:
06h36m03s- filename a
06h36m05s- filename b
06h36m12s- filename c
06h36m21s- filename d
06h36m33s- filename e
...
to padded from 1-9 if more than 9
i.e., if above went to 10 and beyond
to:
06h36.1- filename a
06h36.2- filename b
06h36.3- filename c
06h36.4- filename d
06h36.5- filename e
to padded from 1-9 if more than 9:
06h36.01- filename a
06h36.02- filename b
06h36.03- filename c
06h36.04- filename d
06h36.05- filename e
06h36.06- filename f
06h36.07- filename g
06h36.08- filename h
06h36.09- filename i
06h36.10- filename j
06h36.11- filename k
I know it's a tall order but my renamer handled this type of complexity and more! I had files generated by screenshot app and recorded radio programs with all sorts of different naming conventions, and for years I used this app with perfect results. It's just that in the switch to a new computer, and all but 1 backup option, I lost of my years of scripting.
Any help appreciated! Thanks!
|
|
|
|
|
Personally I'm confused by what you say concerning the fabrication of "seconds" from the original set of strings returned. How do you account for the fact that sequentially, 10 (counting ten) tenths adds up to one? "Over 9 files": what the heck does that mean?
In my defense I'd also like to point out that after many years of observing columns of Date Modified, Date Created, Date Accessed windows time stamps (even in MSDOS this is true), what shows is ALWAYS sortable as some "true" time. Despite two "time stamps" of the same look, underneath the msification is a millisecond disposition.
Am not making any sense of this am I?
|
|
|
|
|
I want to be able to use the content of a database table as part of a regex expression. This isn't the actual use case, but it shows what I want to do.
Database table includes a field with customer names, "Acme","Starbucks","Delta". This table gets updated with new customers daily.
I have a simple RegEx that looks for the existence of some text in an OCR'd document. (?i)(Acme|Starbucks|Delta)
I want to update the RegEx statement with the new entries. I know I can do it through some external scripting, but what I would like to do is embed some sort of call to the table and column a the time of execution, like "(?i)(ODBC Hook to the data here)"
|
|
|
|
|
Assuming that the regex engine you are using supports the dotall operator, you can use the following:
'\*\*\* START FAILSAFE \*\*\*\*\*\*\*\*\*(.*?)'\*\*\* STOP FAILSAFE \*\*\*\*\*\*\*\*\*\* Alternatively, you could use
'\*\*\* START FAILSAFE \*\*\*\*\*\*\*\*\*[\w\W]*?'\*\*\* STOP FAILSAFE \*\*\*\*\*\*\*\*\*\*
|
|
|
|
|
I am having a text file having some text to be remove enclosed within a defined tag (234 in the example below). This to-be removed text is not fixed and can occur multiple times in a single line OR can be spanned across multiple lines.
Example -
aaaaaaaaaaa234textA234aaaaa
234text234
blank line
bbbbbb234textB234bbbbbb
ccccc234te
xtC234
dddd234TextD234dddd
With this expression- "(\d)([\s\S]*?)(\d)", I am able to find out and replace the text with "" as expected but the problem occurs wherein the line ends with the tag (234) and the same line either starts with the tag (234) or in the continuation to the previous line like lines 2 and 6 in the above example. The problem is, line 2 and 6 are leaving a blank line behind and so the output contains 7 lines while I am expecting 5 lines (line 2 and 6 should be removed) only.
Please suggest.
|
|
|
|
|
I'd use a text (file) editor and do a replace all.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Hi,
I'm trying to figure how to 'find and replace' a textstring within a textfile. But the find and replace within the file has to only start after a certain textstring and it also has to stop before a second textstring. Can that be done with regex? Or would that require code (Python for instance).
Kind regards,
Roland
|
|
|
|
|
(?!^.*((Practice)|(ARCHIVE)|(CpSystem)|(RESTORE)).*$)(^\s*\w*)
Want to make Practice, Archive, CPSystem, and Restore case insensative.
I tried
(?i)(?!^.*((Practice)|(ARCHIVE)|(CpSystem)|(RESTORE)).*$)(^\s*\w*)
And
(?!^.*((?i)(Practice)|(?i)(ARCHIVE)|(?i)(CpSystem)|(?i)(RESTORE)).*$)(^\s*\w*)
Neither worked.
Any advise?
D
|
|
|
|
|
|
I have an alias.txt file that looks like this
CHALET_HIST_ARCHIVE - zz** Chalet History Archive **zz
CHALET_Practice - CHALET Retail ***Practice***
CHALET - CHALET
CPPractice - ***NCR Practice***
LANDSCAPE_Practice - CHALET Landscape ***Practice***
LANDSCAPE - CHALET LANDSCAPE
THALMANN - Thalmann Farm
CpSystem - CPSQL System Database
The value to the left of the dash is the alias name. I need to return all alias names that do not contain PRACTICE, ARCHIVE, RESTORE, or CPSYSTEM (regardless of case).
In the list above, the only valid values returned would be THALMANN, CHALET, and LANDSCAPE. All the others should be ignored as containing one of the above words to eliminate the result.
No white space before or after the returned value.
Currently i am at:
^\s*\w*
Which accurately includes everything left of the dash, but does not eliminate the above results containing one of the four words.
Any advise?
Dj
modified 20-Dec-21 12:16pm.
|
|
|
|
|
|
Hi!
Could anyone pls help med with a regex that extracts row 3 (Summer AB) only?
805
1506678441522
Summer AB
4302334
4302334
Structure
DBT.4302334"
|
|
|
|
|
I've a weird situation. I created a regex expression for one of the service. I've tested this expression at regexr.com and regex101.com and there are no problems at all. when I used this regex expression in fail2ban, it missed all the lines.
here is the log output;
[05-Oct-2021 17:09:39 +0300]: IMAP Error: Login failed for xyz@xyz.com against localhost from 95.65.143.88. AUTHENTICATE PLAIN: Authentication failed. in /usr/share/roundcube/program/lib/Roundcube/rcube_imap.php on line 204 (POST /webmail/?_task=login&_action=login)
here is the regex;
(IMAP Error: Login failed for)\s([a-zA-Z0-9_.-]+\@[a-zA-Z0-9_.-]+)\s(against localhost from)\s
is fail2ban using a different regex structure?
|
|
|
|
|
|
fail2ban is checking application logs and prevent intruders.
|
|
|
|
|
fail2ban regexes are a bit "different", particularly with the new(ish) prefixes and interpolations.
Your best bet is to use "fail2ban-regex".
Somewhere around the fail2ban site there is a tutorial about iincremental development of regexes.
It's a bit outdated, but the process works.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
yep I'm using fail2ban-regex but before that I'm preparing my expressions at regexr.com.
|
|
|
|
|
My experience with fail2ban regexes is that they are sufficiently different from the "standard" ones that the regular development/test tools don't help.
I think you're stuck with fail2ban-regex, a dummy log file with examples of good and bad entries, and a whole lot of panel-beating, depending on how complex your requirements are.
It's worth looking at the various filter files provided with fail2ban. I found some helpful constructs in ones I don't actually use.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
f2b should have provided standard regex expressions, so people wouldn't need to learn something else.
|
|
|
|
|
Hi,
im relatively new to regex and im trying to match OU from the Distinguished Name in ActiveDirectory.
This is my existing regex:
(((OU=.*?))?)OU=(?<ouname>.*?(?=,))
CN=Muster\, Max,[OU=AAD-Sync,OU=IT-Abteilung],[OU=FD] 10,DC=landkreis-Musterstadt,DC=local
So far this would match the OU I marked with [] as two separate Matches, does anyone know ow to edit my existing regex that it matches every OU as one Match instead of two separates?
Would be lovely if I could get some Help
|
|
|
|
|
I have this regex to replace accents but it fails if the text contains "|".
string Text = "word|word2";
System.Text.RegularExpressions.Regex replace_a_Accents = new System.Text.RegularExpressions.Regex("[á|à|ä|â]", System.Text.RegularExpressions.RegexOptions.Compiled);
System.Text.RegularExpressions.Regex replace_e_Accents = new System.Text.RegularExpressions.Regex("[é|è|ë|ê]", System.Text.RegularExpressions.RegexOptions.Compiled);
System.Text.RegularExpressions.Regex replace_i_Accents = new System.Text.RegularExpressions.Regex("[í|ì|ï|î]", System.Text.RegularExpressions.RegexOptions.Compiled);
System.Text.RegularExpressions.Regex replace_o_Accents = new System.Text.RegularExpressions.Regex("[ó|ò|ö|ô]", System.Text.RegularExpressions.RegexOptions.Compiled);
System.Text.RegularExpressions.Regex replace_u_Accents = new System.Text.RegularExpressions.Regex("[ú|ù|ü|û]", System.Text.RegularExpressions.RegexOptions.Compiled);
Texto_Retorno = replace_a_Accents.Replace(Texto_Retorno, "a");
Texto_Retorno = replace_e_Accents.Replace(Texto_Retorno, "e");
Texto_Retorno = replace_i_Accents.Replace(Texto_Retorno, "i");
Texto_Retorno = replace_o_Accents.Replace(Texto_Retorno, "o");
Texto_Retorno = replace_u_Accents.Replace(Texto_Retorno, "u");
|
|
|
|
|
Why would you use a Regex for something so simple?
bool replacedAny = false;
char[] characters = Texto_Retorno.ToCharArray();
for (int index = 0; index < characters.Length; index++)
{
switch (characters[index])
{
case 'á':
case 'à':
case 'ä':
case 'â':
{
characters[index] = 'a';
replacedAny = true;
break;
}
case 'é':
case 'è':
case 'ë':
case 'ê':
{
characters[index] = 'e';
replacedAny = true;
break;
}
case 'í':
case 'ì':
case 'ï':
case 'î':
{
characters[index] = 'i';
replacedAny = true;
break;
}
case 'ó':
case 'ò':
case 'ö':
case 'ô':
{
characters[index] = 'o';
replacedAny = true;
break;
}
case 'ú':
case 'ù':
case 'ü':
case 'û':
{
characters[index] = 'u';
replacedAny = true;
break;
}
}
}
if (replacedAny)
{
Texto_Retorno = new string(characters);
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
modified 16-Sep-21 10:54am.
|
|
|
|
|
|
Nothing to see here. :innocent-whistle-smily:
In my defence, "3" is directly above "e" on the keyboard.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|