docusnap-dude
Goto Top

RegExpressionprüfung Ganzzahl 1-365

Hallo,

ich verzweifle mal wieder mit RegExtensions....Wenn da mal einer eine RegEX-Builder bauen würde...HURRA!!

Folgendes: ich brauch die Prüfung für "1 Tag bis 365 Tage" (also positive Ganzzahl 1-365, 1bis 3 Stellen lang, führende Nullen können weg bleiben)

Würde da so rangehen:
^[0-3][0-9][0-9]{0,3}$

Aber damit geht eben auch "399". Das ist natürlich Mist. genauso wie "99" nicht geht aber "099" geht. Hmmm...

Habt ihr da eine Lösung? Merci!!!

Content-Key: 628232

Url: https://administrator.de/contentid/628232

Ausgedruckt am: 29.03.2024 um 08:03 Uhr

Mitglied: saggi20
Lösung saggi20 04.12.2020 um 09:04:31 Uhr
Goto Top
Hallo,

das
^([1-9]|[1-9][0-9]|[1-2][0-9]{2}|3[0-5][0-9]|36[0-5])$
sollte funktionieren.

saggi
Mitglied: DocuSnap-Dude
DocuSnap-Dude 04.12.2020 um 09:11:28 Uhr
Goto Top
Danke dir, das rockt!
Mitglied: Lochkartenstanzer
Lochkartenstanzer 04.12.2020 um 10:19:44 Uhr
Goto Top
Zitat von @DocuSnap-Dude:

Danke dir, das rockt!

Hast Du auch den Lösungsweg verstanden oder hält das nur bis zum nächsten Problem?

lks
Mitglied: 146707
Lösung 146707 04.12.2020 aktualisiert um 12:09:56 Uhr
Goto Top
Zitat von @Lochkartenstanzer:
Hast Du auch den Lösungsweg verstanden oder hält das nur bis zum nächsten Problem?
Dem Teaser seines Profils zu urteilen, eher letzteres face-wink.

^([1-9]|[1-9][0-9]|[1-2][0-9]{2}|3[0-5][0-9]|36[0-5])$

Assert position at the beginning of a line (at beginning of the string or after a line break character) (line feed) «^»
Match the regex below and capture its match into backreference number 1 «([1-9]|[1-9][0-9]|[1-2][0-9]{2}|3[0-5][0-9]|36[0-5])»
   Match this alternative (attempting the next alternative only if this one fails) «[1-9]»
      Match a single character in the range between “1” and “9” «[1-9]»
   Or match this alternative (attempting the next alternative only if this one fails) «[1-9][0-9]»
      Match a single character in the range between “1” and “9” «[1-9]»
      Match a single character in the range between “0” and “9” «[0-9]»
   Or match this alternative (attempting the next alternative only if this one fails) «[1-2][0-9]{2}»
      Match a single character in the range between “1” and “2” «[1-2]»
      Match a single character in the range between “0” and “9” «[0-9]{2}»
         Exactly 2 times «{2}»
   Or match this alternative (attempting the next alternative only if this one fails) «3[0-5][0-9]»
      Match the character “3” literally «3»
      Match a single character in the range between “0” and “5” «[0-5]»
      Match a single character in the range between “0” and “9” «[0-9]»
   Or match this alternative (the entire group fails if this one fails to match) «36[0-5]»
      Match the character string “36” literally «36»
      Match a single character in the range between “0” and “5” «[0-5]»
Assert position at the end of a line (at the end of the string or before a line break character) (line feed) «$»
Mitglied: DocuSnap-Dude
DocuSnap-Dude 24.02.2021 um 10:23:25 Uhr
Goto Top
Zitat von @Lochkartenstanzer:

Zitat von @DocuSnap-Dude:

Danke dir, das rockt!

Hast Du auch den Lösungsweg verstanden oder hält das nur bis zum nächsten Problem?

lks

Bisher ja, habe einige sachen damit gebaut in letzter Zeit.