xr18b,
@xr18b@mstdn.social avatar

Today I realise that the ASCII code for '*' (the wildcard in regex) is 42.
Which means that, in “The Hitchhiker's Guide to the Galaxy”, when Deep Thought replied ‘42’ to "What is the answer to life, the universe, and everything?", it actually meant "Anything you want"

dabeaz,
@dabeaz@mastodon.social avatar

@xr18b Now, just wait until you realize what part of the statement might explain the 7.5 million year computation time. ;-).

prefec2,
@prefec2@norden.social avatar

@xr18b this makes way too much sense and could result in a replacement of the universe by something even more bizzare. However, this might have happened already.

slink,
@slink@fosstodon.org avatar
feld,
@feld@bikeshed.party avatar

deleted_by_author

  • Loading...
  • mensrea,
    @mensrea@freeradical.zone avatar

    @feld it was. the early mac he was using to write the stories didn't use ascii and he said many times he just though 42 was a humorous number @xr18b

    paddi,

    @xr18b '*' isn't the wildcard in RegEx?!
    '.' is.

    '*' means "0 or more repetitions of the thing before it" (https://en.wikipedia.org/wiki/Kleene_star)

    xr18b,
    @xr18b@mstdn.social avatar

    @paddi it depends on the type of regex.
    In POIX regex, you are right.
    But it is not always the case. For instance, in a SHELL, cat *.txt will cat all files ending with .txt

    paddi,

    @xr18b 👍 thanks for the explaination.
    But is Filename Expansion really a sort of RegEx? (Don't get me wrong please I'm really just curious)

    grindhold,
    @grindhold@chaos.social avatar

    @paddi @xr18b you are formally right. yes. there is no such thing as a real wildcard in regex. "." in regex is "one arbitrary character". you can expand using * or + to "zero or more arbitrary characters" or "one or more arbitrary characters" respectively. as such , * takes the role of a quantifier rather than a wildcard. the * in filename expansion is not a regex in the mathematical sense. as it is not mighty enough to parse a regular language.

    grindhold,
    @grindhold@chaos.social avatar

    @paddi @xr18b altough i could imagine there is some sick fuck around here who's bored enough to prove me wrong on that last claim. i've seen weirder things been proven turing-complete in my life.

    prefec2,
    @prefec2@norden.social avatar

    @grindhold @paddi @xr18b the pattern rules for shells are also regular expressions, but less expressive that POSIX or Perl regex.

    Essentially regex is a class of language which can be accepted by a simple automaton.
    You can even map shell regex to other kinds of regex.

    • -> .*
      ? -> .
      any character -> any character

    As I am lazy, I also link the first thing on regex I found:
    https://en.wikipedia.org/wiki/Regular_expression?wprov=sfla1

    paddi,

    @prefec2 yupp, we covered this during my CS elective too - but thank you for the reminder, I appreciate it :D

    I just wasn't sure whether the pattern matching of shells is equivalently mighty to RegExes - and to answer my own question: It seems like with 'extglob' enabled they are

    paddi,

    @prefec2 (and as always there is a (more-or-less)-fitting XKCD comic https://xkcd.com/1053/ 😉 )

    prefec2,
    @prefec2@norden.social avatar

    @paddi ah XKCD I went to that course too.😄

    The question whether it is as powerful as Perl regex is interesting, but I am only a software engineer and forgot everything in that area. My hunch is no, but that is no proof at all.

    nf3xn, (edited )
    @nf3xn@mastodon.social avatar

    @paddi @xr18b No it isn't. * does nothing on its own. It is technically a qualifier not a wildcard. Though there would be nothing wrong with writing a program that could accept them as file globbing arguments apart from the fact the dots always need to be escaped.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • kavyap
  • DreamBathrooms
  • cisconetworking
  • osvaldo12
  • ngwrru68w68
  • magazineikmin
  • thenastyranch
  • Youngstown
  • ethstaker
  • rosin
  • slotface
  • mdbf
  • tacticalgear
  • InstantRegret
  • JUstTest
  • Durango
  • tester
  • everett
  • cubers
  • GTA5RPClips
  • khanakhh
  • provamag3
  • modclub
  • Leos
  • normalnudes
  • megavids
  • anitta
  • lostlight
  • All magazines