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

Printed on: April 16, 2024 at 19:04 o'clock

Member: saggi20
Solution saggi20 Dec 04, 2020 at 08:04:31 (UTC)
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
Member: DocuSnap-Dude
DocuSnap-Dude Dec 04, 2020 at 08:11:28 (UTC)
Goto Top
Danke dir, das rockt!
Member: Lochkartenstanzer
Lochkartenstanzer Dec 04, 2020 at 09:19:44 (UTC)
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
Solution 146707 Dec 04, 2020 updated at 11:09:56 (UTC)
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) «$»
Member: DocuSnap-Dude
DocuSnap-Dude Feb 24, 2021 at 09:23:25 (UTC)
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.