question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"var-1" is divided incorrectly into "var" and "-1"

See original GitHub issue

In Python mode (not sure whether this bug also exist in other language), var-1 should be divided into var (variable, which will be a text node after parsing), - (operator) , and 1 (number) . However, when there is no space between “-” and “1”, the string will be divided into var and -1(number).

image

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
zeitgeist87commented, Mar 23, 2017

The behavior is a bit inconsistent. The problem is, that the number definition for most languages begins with the following regex \b-?. The minus sign can also be a word boundary at the same time and \b is a zero-length match. This complicates things a bit:

  • Case word -1: The zero-length \b matches between - and 1 because - is seen as a word boundary. So - will become an operator and 1 will be a number.
  • Case word-1: The \b matches the end of word between d and -. This time - is part of the number.

We could make it more consistent and remove all -? from the number definitions of all languages. Then it would always be an operator.

0reactions
LeaVeroucommented, Mar 25, 2017

Ok! Would probably simplify some regexps too 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trying to split a string into two variables - bash - Stack Overflow
Since that word does not contain a : , read does not split it into two words, and the entire string is assigned...
Read more >
$VAR vs ${VAR} and to quote or not to quote
Using quotes around a variable as in rm -- "$VAR1" or rm -- "${VAR}" is a good idea. This makes the contents of...
Read more >
Dividing by category of a categorical variable - Statalist
Hello all, Let's say I have a categorical variable, var1, with 3 categories: category count 1 350 2 260.
Read more >
How do I calculate a new variable based on values of ... - IBM
The syntax below first generates a sample data file. Then it computes newvar based on what the values of var1 and var2 are....
Read more >
How to Combine Two or More Categorical Variables into One ...
COMPUTE newvar = (var1 - 1) * 3 + (var2 - 1) + 1. EXECUTE. If you don't know that: DO IF ANY(var1,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found