Click here to Skip to main content
15,886,873 members
Home / Discussions / Regular Expressions
   

Regular Expressions

 
AnswerRe: Regular expression for City name Pin
k50547-Feb-24 20:02
mvek50547-Feb-24 20:02 
AnswerRe: Regular expression for City name Pin
Pete O'Hanlon8-Feb-24 4:10
mvePete O'Hanlon8-Feb-24 4:10 
AnswerRe: Regular expression for City name Pin
jschell8-Feb-24 4:58
jschell8-Feb-24 4:58 
GeneralRe: Regular expression for City name Pin
Richard Deeming8-Feb-24 5:07
mveRichard Deeming8-Feb-24 5:07 
GeneralRe: Regular expression for City name Pin
jschell9-Feb-24 12:02
jschell9-Feb-24 12:02 
QuestionDoes anyone have experience with creating the regex rule for a fail2ban filter? Pin
Member 161948782-Feb-24 4:44
Member 161948782-Feb-24 4:44 
AnswerRe: Does anyone have experience with creating the regex rule for a fail2ban filter? Pin
jschell7-Feb-24 5:38
jschell7-Feb-24 5:38 
QuestionHelp for a regexp Pin
Member 1616830421-Dec-23 23:43
Member 1616830421-Dec-23 23:43 
Good morning

I need to "purify" sentences to be able to use them in an app.
Thanks a lot for your help in helping me build the right code Smile | :)

I think the pattern is:

- 'any sentence' (0 or 1 time) {text here} (0-N times)

example
AB CD {xxxxx}
or AB CD {xxxxx,yyyy}
or {xxxxx}
or AB CD
or AB CD {xxxxx} AB CD {xxxxx}
or AB CD {xxxxx} {xxxxx} {xxxxx}
etc


- the {text here} block looks like {digit|some text}.
For example:
{1|xxxxxxxxx}

- the 'some text' block can (not mandatory) contain 'default=xxx' at any place in the text

ex: {3|abc=d,default=my value} or {2|a b c=d,default=my value,another=valueThatIDontNeed} or {1|default=my value}

I need to isolate the following parts and return them to a string.
- 'any sentence' text (if exists)
- xxx of the 'default=xxx' pattern, as per above explanation

This does not need to be done in one pass, I can script that in loops in Python for example.

Here are a few examples

Example 1
Store bulk masses greater than {0|message=<specify mass="" value="">|filter=^(_)?MASS_VALUE.+|add space after=false.+}{1|message=<specify mass="" unit="">|filter=^(_)?P413_MASS_UNIT.+} at temperatures not exceeding {2|message=<specify temperature="" value="">|filter=^(_)?TEMP_VALUE_.+|add space after=false.+}{3|message=<specify temperature="" unit="">|filter=^(_)?P413_TEMP_UNIT_.+}

this should give
Store bulk masses greater than at temperatures not exceeding

Example 2
Inhoud onder {0|message=<geschikt(e) vloeistof="" of="" gas="" specificeren="">|default=inert gas|filter=^(_)?P231_STORAGE_.+} gebruiken en bewaren. Tegen vocht beschermen.

Should give
Inhoud onder inert gas gebruiken en bewaren. Tegen vocht beschermen.

Example 3
EN CAS DE CONTACT AVEC LA PEAU: Laver abondamment{0|message=<préciser un="" produit="" de="" nettoyage="">|default=à l’eau|filter=^(_)?P352_WASH_.+}. Appeler immédiatement {1|message=<préciser qui="" pourra="" émettre="" comme="" il="" convient="" n="" avis="" médical="" en="" cas="" d’urgence="">|default=un CENTRE ANTIPOISON ou un médecin|filter=^(_)?P310_EMERGENCY_.+}.

Should give
EN CAS DE CONTACT AVEC LA PEAU: Laver abondamment à l’eau . Appeler immédiatement un CENTRE ANTIPOISON ou un médecin

Example 4

{0|message=<specificeren of="" dumpingvoorschriften="" van="" toepassing="" zijn="" op="" inhoud,="" container="">|default=Inhoud/verpakking|filter=^(_)?P501_REQUIREMENT_.+} afvoeren naar {1|message=<specificeer welke="" lokale="" regionale="" nationale="" internationale="" wetgeving="">|default=…|filter=^(_)?P501_DISPOSAL_.+}.

Should give
Inhoud/verpakking afvoeren naar … .


thanks !
AnswerRe: Help for a regexp Pin
Member 1616830422-Dec-23 2:53
Member 1616830422-Dec-23 2:53 
QuestionRegex: more than one identical character next to each other? Pin
Member 1615168129-Nov-23 7:07
Member 1615168129-Nov-23 7:07 
AnswerRe: Regex: more than one identical character next to each other? Pin
Richard Deeming29-Nov-23 22:28
mveRichard Deeming29-Nov-23 22:28 
QuestionHelp me regexp gurus please problem is matching files and copy Pin
Gin Mador11-Nov-23 15:27
Gin Mador11-Nov-23 15:27 
AnswerRe: Help me regexp gurus please problem is matching files and copy Pin
jschell30-Nov-23 6:17
jschell30-Nov-23 6:17 
Questionpattern replace with specific exception Pin
Member 1612263424-Oct-23 1:06
Member 1612263424-Oct-23 1:06 
AnswerRe: pattern replace with specific exception Pin
Member 1612263426-Oct-23 1:02
Member 1612263426-Oct-23 1:02 
AnswerRe: pattern replace with specific exception Pin
Justice Marc20-Nov-23 5:10
Justice Marc20-Nov-23 5:10 
QuestionReplacement of initial words Pin
Luca Smith12-Oct-23 0:47
Luca Smith12-Oct-23 0:47 
AnswerRe: Replacement of initial words Pin
OriginalGriff12-Oct-23 0:50
mveOriginalGriff12-Oct-23 0:50 
GeneralRe: Replacement of initial words Pin
Luca Smith12-Oct-23 0:54
Luca Smith12-Oct-23 0:54 
GeneralRe: Replacement of initial words Pin
OriginalGriff12-Oct-23 1:18
mveOriginalGriff12-Oct-23 1:18 
GeneralRe: Replacement of initial words Pin
Luca Smith12-Oct-23 1:40
Luca Smith12-Oct-23 1:40 
GeneralRe: Replacement of initial words Pin
Dave Kreskowiak12-Oct-23 3:02
mveDave Kreskowiak12-Oct-23 3:02 
AnswerRe: Replacement of initial words Pin
Richard Deeming12-Oct-23 1:45
mveRichard Deeming12-Oct-23 1:45 
GeneralRe: Replacement of initial words Pin
Luca Smith12-Oct-23 1:59
Luca Smith12-Oct-23 1:59 
GeneralRe: Replacement of initial words Pin
Dave Kreskowiak12-Oct-23 3:01
mveDave Kreskowiak12-Oct-23 3:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.