Lurker News

Comments (129) 40 threads

Earlier comments
philshem2 replies#
I have a secret hobby of answering python + regex questions on stackoverflow with pure python.
geongeorgek#
I'm gonna pretend I didn't read this
johnnylambada1 reply#
Examples?
philshem#
_secret_
vzidex1 reply#
Very cool! The site that worked best for me to learn regex was https://regexcrossword.com/ - after solving my way through all of them (I got really hooked when I discovered the site) I found I was alright at regex.
geongeorgek#
Thank you for sharing that. looks good
adambowles1 reply#
>/h.llo/ the '.' matches any one character other than a new line character... matches 'hello', 'hallo' but not 'h llo'

in the cheatsheet is false. (https://regexr.com/4tc48)
`.` can match any character except linebreaks (including whitespace)

jodrellblank#
`.` "can" match any character including linebreaks if the regex engine is in re.DOTALL mode (Python) or SingleLine Mode (.Net).
dana3211 reply#
One thing i've always missed from the Perl programming language is the regex operators.

You could do:

  my $var='foo foo bar and more bar foo!!!';

  if($var=~/(foo|bar)/g){  # does the variable contain foo or bar?

    print "foo! $1 removing foo..\n";

    # remove our value..

    $var=~s/$1//g;

  }
dana321#
Awesome job, i did a hack bootstrapping the tokenizer to do the same thing in php, didn't release it though.

Load more comments