JavaScript Regex for non zero negative decimal number regex negative zero,regex zero-width negative lookahead,java regex

I am using ^-\d*\.?\d+$ for negative number matching. But this accepts -0. I want to restrict the regexp from matching -0. Can some one help? Thanks in advance.

Answer:1

You may use

^-(?!0*\.?0+$)\d*\.?\d+$
  ^^^^^^^^^^^^

See the regex demo

The (?!0*\.?0+$) negative lookahead fails the match if the string only contains -, and then an int/float like number that represents a zero.

Details:

  • ^ - start of string
  • - - a hyphen
  • (?!0*\.?0+$) - after the current position, fail the match if the following pattern is matched:
    • 0* - zero or more 0s
    • \.? - an optional .
    • 0+ - 1 or more 0s
    • $ - end of string
  • \d* - 0+ digits
  • \.? - an optional .
  • \d+ - 1 or more digits
  • $ - end of string.
Answer:2

I'm using Ionic 3. I used ion-datetime component: myDate: String = new Date().toISOString(); <ion-datetime displayFormat="HH:mm" pickerFormat="HH:mm" [(ngModel)]="myDate"></ion-datetime> ...

I'm using Ionic 3. I used ion-datetime component: myDate: String = new Date().toISOString(); <ion-datetime displayFormat="HH:mm" pickerFormat="HH:mm" [(ngModel)]="myDate"></ion-datetime> ...

  1. ionic datetime default value
  2. ionic datetime set default value
  3. ionic ion-datetime default value
  4. ionic 3 datetime default value
  5. ionic 2 ion-datetime default value

I have this html code i want to make the color divs draggable and then fit them in the table cell aside the green div should fit 2 cell spaces, the light blue 3 cell spaces, the yellow 4 cell spaces ...

I have this html code i want to make the color divs draggable and then fit them in the table cell aside the green div should fit 2 cell spaces, the light blue 3 cell spaces, the yellow 4 cell spaces ...

public onChange(event: Event) { let files = event.target['files']; let list: string[]; console.log(files); for (var i = 0; i < files.length; i++) { if (FileReader && ...

public onChange(event: Event) { let files = event.target['files']; let list: string[]; console.log(files); for (var i = 0; i < files.length; i++) { if (FileReader && ...

  1. undefined array value javascript
  2. undefined array size java
  3. undefined array size
  4. undefined array size c
  5. undefined array c++
  6. undefined array typescript
  7. undefined array python
  8. undefined array angular
  9. undefined array java
  10. undefined array php
  11. undefined array js
  12. undefined array length javascript
  13. undefined array element javascript
  14. undefined array vba
  15. undefined array length java
  16. undefined array length c
  17. undefined array size vba
  18. undefined array element
  19. undefined array in perl
  20. undefined array angular2

Here is my code: $('body').not('.specific_element').css('opacity','.3'); body{ border: 1px solid; } .specific_element{ border: 1px solid red; } <script src="https://ajax.googleapis....

Here is my code: $('body').not('.specific_element').css('opacity','.3'); body{ border: 1px solid; } .specific_element{ border: 1px solid red; } <script src="https://ajax.googleapis....

  1. donald trump
  2. donovan mitchell
  3. donald trump twitter
  4. don toliver
  5. donuts
  6. donald trump age
  7. donatos
  8. donald glover
  9. donald trump net worth
  10. donuts near me
  11. donald trump jr
  12. donepezil
  13. don johnson
  14. donald trump speech today
  15. donna shalala
  16. donna summer
  17. donald cerrone
  18. don julio
  19. donnie darko
  20. don quixote