|
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
|
|
|
|
|
Given some of the nonsense that appears when I type too fast I think you do very well.
|
|
|
|
|
I was dreading it, Regex doesn't do the job and doesn't replace either?
|
|
|
|
|
Regex can do the job. But running five+ separate regex operations on a string just to replace a few letters with their unaccented alternatives is overkill.
The other option, which is even nastier and less obvious, is to use Unicode normalization:
static string RemoveDiacritics(string stIn)
{
string stFormD = stIn.Normalize(NormalizationForm.FormD);
StringBuilder sb = new StringBuilder();
for(int ich = 0; ich < stFormD.Length; ich++)
{
UnicodeCategory uc = CharUnicodeInfo.GetUnicodeCategory(stFormD[ich]);
if (uc != UnicodeCategory.NonSpacingMark)
{
sb.Append(stFormD[ich]);
}
}
return sb.ToString().Normalize(NormalizationForm.FormC);
}
string input = "Príliš žlutoucký kun úpel dábelské ódy.";
string result = RemoveDiacritics(input); Source[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
case 'Á' case 'À' case 'Ó' ... to be continue
|
|
|
|
|
In [...] groups (alternatives) you don't want the |s.
[aeiou] as a regex will match any vowel, for example.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
I use Regex match to find multiple words in Like mode (start and end point). I do not want the return to include the space as the first position and I do not want the final space to count as valid.
Regular Expression: "\b(?:.Road.|.ous.|.Street.)\b" Must Return: Match:9 length:5 End:13
Text: "have one house free."
|
|
|
|
|
Hello there, I have a string that looks like this
\abc\rvr\sad\dqwdwq Some text \rfdqwdvr\rtgevr\rgwvrr\23rvrv Some text \rffewvr\rfewvr\rvfewrr\rvrwefewv
I want to match the parts of the string that are connected by the backslashes. I partially achieved this with
[\\][A-z0-9]+ but this only matches the first one. How can I match every part with backslashes in this string?
Thanks
modified 31-Aug-21 8:08am.
|
|
|
|
|
Assuming you want to extract three strings:
- \abc\rvr\sad\dqwdwq
- \rfdqwdvr\rtgevr\rgwvrr\23rvrv
- \rffewvr\rfewvr\rvfewrr\rvrwefewv
Try:
([\\][A-Za-z0-9]+)+ Regexper[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
hi would any one have a regex that would match (aug -) or(july -) or (june -)without the brackets
but would not match just (aug)or (july) or (june)
So far i have
\W*((?i)aug -(?-i))\W*
but this also matches aug which i dont want thanks
|
|
|
|
|
I tried your regex in Expresso, and it matches "hello aug -goodbye" but not "hello aug goodbye".
So ... what are you talking about?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
im using regex in placemint for placement of window and brousers
if i title a folder aug placemint macthes it , but i only want match on aug -
|
|
|
|
|
Im no ideas what should be captured, so Im guessing that it should include alternates like...
\W*(?i)((?:aug|july|june)(?-i) -)\W*
Except that both \W* are redundant since they allow 0-occurrences, so they dont alter any matched text.
Its best to include samples to keep the experts from guessing, so I will try to save them some troubles...
Capture 'aug' or 'July' or 'JUNE' as whole words if followed by: 1-space, 1-hyphen, 0-or-1 space, and a 1-or-2 digit word.
.*\W(?i)(aug|july|june(?-i)) - ?\d{1,2}\W.*
Capture 'aug -' or 'July -' or 'JUNE -' with the same conditions...
.*\W(?i)((?:aug|july|june(?-i)) -) ?\d{1,2}\W.*
Capture 'aug -##' or 'July - ##' or 'JUNE - ##' with the same conditions...
.*\W(?i)((?:aug|july|june(?-i)) - ?\d{1,2})\W.*
Capture 'aug -' or 'July -' or 'JUNE -' as whole words, but only if - is followed by a non-word character like %.
This does seem the most unlikely, but Im trying to copy your original match, because no samples are being posted...
.*\W(?i)((?:aug|july|june)(?-i) -)\W.*
If none of these match properly, you should include samples of your text lines, and say what should be captured.
There is many experts who is not even going to answer, without first seeing some samples.
modified 5-Oct-21 21:01pm.
|
|
|
|
|
Thanks for trying to help me with this, im a complete novice with regex
i am trying to capture 'aug -' or 'July -' or 'JUNE -'
sentance 'the aug' = would not match
sentance 'aug1' = would not match
sentance 'aug -2' = would not match
sentance 'aug -' = would match
|
|
|
|
|
Im guessing that you posted 4 complete samples, and that 'sentance' means 1 whole line?...
\b(?i)((?:aug|july|june)(?-i) -)$
modified 5-Oct-21 21:01pm.
|
|
|
|
|
yes thanks sentance means 1 whole line,
i tried \b(?i)((?:aug|july|june)(?-i) -)$
but its not matching anything
|
|
|
|
|
Its a PCRE regex to capture text just like your 4th-sample, so matching any lines that end like...
aug -
Maybe you're using something else?? Not using $1 or \1 for replace?? Not giving full samples??
modified 5-Oct-21 21:01pm.
|
|
|
|
|
example i use
\W*((?i)ALARM CLOCK(?-i))\W*
so any window that says alarm clock is placed at same position on desktop
|
|
|
|