News for hackers. Stuff that matters.
Re:The New ‘Absent Operator’ in Ruby’s Regular Expressions by rntz on Thursday March 23, 2017 @10:55AM (#13940236)
You propose:

    (?=((?!exp).)*$)
I don't believe you're right, but can't be sure, because you haven't given a method of translating an arbitrary regular expression containing a negation (?~E) into one without.

For example, how would you translate:

    (?~exp)a.*
which asks for "anything not exp, then an `a`, then anything"?

    (?=((?!exp).)*$).*a.*
is wrong, since it doesn't match "aexp".

    (?=((?!exp).)*$)a.*
is also wrong, for the same reason.

    (?=((?!exp).)*a)a.*
is wrong, because it doesn't match "expba".

EDIT: argh, HN formatting rules about asterisks.

Re:The New ‘Absent Operator’ in Ruby’s Regular Expressions by mnarayan01 on Thursday March 23, 2017 @11:38AM (#13940697)
I believe he's saying you'd want:

  (?=((?!exp).)*a.*)
I'm a little dubious that full equivalence is maintained (particularly w.r.t. to e.g. #match), but my brain isn't up to handling convoluted REs this early.

Edit: Another hangup I have is how would you do something like:

  ((?~E1)|E2)E3
Obviously you can distribute by duplicating E3, but then it's pretty clear what the absent operator buys you.
Re:The New ‘Absent Operator’ in Ruby’s Regular Expressions by rntz on Thursday March 23, 2017 @02:23PM (#13942564)

    (?=((?!exp).)*a.*)
is also wrong; it doesn't match "expba", but

    (?~exp)a.*
does.
Re:The New ‘Absent Operator’ in Ruby’s Regular Expressions by mnarayan01 on Thursday March 23, 2017 @11:07PM (#13946285)

  /(?=((?!exp).)*a.*)/ =~ "expba"
  # => 1
for me at least (using #match is also truthy, but the matched string is not what I'd guess the absent operator would give).
Re:The New ‘Absent Operator’ in Ruby’s Regular Expressions by rntz on Sunday March 26, 2017 @07:34PM (#13964016)
Huh! Now I am super confused.