I am working on making sure a form input is parsed correctly through google forms and I was trying to use my limited regex knowledge to make sure that people do not input tracts incorrectly.
usually a tract is given in an example such as 5129.01
All tracts in the county start with 5, have a second character that is either a 0 or a 1,and if it is a 1, the third character is either [0 - 3] else its [0-9].
I have a working expression but I would like to ensure that if the second character is a 1 the user wouldn't be able to enter a tract like 5150.01
This is what I have:
^5[0-1]([0-9]{2})(\.([0-9]{2}))?$
and this is what is not working:
^5[0-1](?(?<=1)\d|[0-3])(\.([0-9]{2}))?$
Any help would be appreciated thanks
I hope this answers your question, please comment and I can edit accordingly.
The pattern:
^(?:51[0-3]|50[0-9])[0-9](?:\.[0-9]{1,2})?$
A visual representation:
HTML implementation:
<input name="example" pattern="^(?:51[0-3]|50[0-9])[0-9](?:\.[0-9]{1,2})?$">
Value validation examples:
+----------+--------+
| Value | Status |
+----------+--------+
| 51 | fail |
| 510 | fail |
| 5101 | pass |
| 5111 | pass |
| 5121 | pass |
| 5131 | pass |
| 5141 | fail |
| 5102. | fail |
| 5102.1 | pass |
| 5102.12 | pass |
| 5102.123 | fail |
| 50 | fail |
| 500 | fail |
| 5001 | pass |
| 5011 | pass |
| 5021 | pass |
| 5031 | pass |
| 5041 | pass |
| 5051 | pass |
| 5061 | pass |
| 5071 | pass |
| 5081 | pass |
| 5091 | pass |
| 50911 | fail |
| 5092. | fail |
| 5092.1 | pass |
| 5092.12 | pass |
| 5092.123 | fail |
+----------+--------+
Related
I want to add more rows using the Query editor (Power query/ M Query) in only the Start Date and End Date column:
+----------+------------------+--------------+-----------+-------------+------------+
| Employee | Booking Type | Jobs | WorkLoad% | Start Date | End date |
+----------+------------------+--------------+-----------+-------------+------------+
| John | Chargeable | CNS | 20 | 04/02/2020 | 31/03/2020 |
| John | Chargeable | CNS | 20 | 04/03/2020 | 27/04/2020 |
| Bernard | Vacation/Holiday | SN | 100 | 30/04/2020 | 11/05/2020 |
| Bernard | Vacation/Holiday | Annual leave | 100 | 23/01/2020 | 24/02/2020 |
| Bernard | Chargeable | Tech PLC | 50 | 29/02/2020 | 30/03/2020 |
+----------+------------------+--------------+-----------+-------------+------------+
I want to find the MIN(Start Date) and MAX(End Date) and then append the range of start to end dates to this table only in the Start Date and End Date column in the Query Editor (Power Query/ M Query). Preferrable if I can create another table2 duplicating the original table and append these rows.
For example:
+----------+------------------+--------------+-----------+-------------+------------+
| Employee | Booking Type | Jobs | WorkLoad% | Start Date | End date |
+----------+------------------+--------------+-----------+-------------+------------+
| John | Chargeable | CNS | 20 | 04/02/2020 | 31/03/2020 |
| John | Chargeable | CNS | 20 | 04/03/2020 | 27/04/2020 |
| Bernard | Vacation/Holiday | SN | 100 | 30/04/2020 | 11/05/2020 |
| Bernard | Vacation/Holiday | Annual leave | 100 | 23/01/2020 | 24/02/2020 |
| Bernard | Chargeable | Tech PLC | 50 | 29/02/2020 | 30/03/2020 |
| | | | | 23/01/2020 | 23/01/2020 |
| | | | | 24/01/2020 | 24/01/2020 |
| | | | | 25/01/2020 | 25/01/2020 |
| | | | | 26/01/2020 | 26/01/2020 |
| | | | | 27/01/2020 | 27/01/2020 |
| | | | | 28/01/2020 | 28/01/2020 |
| | | | | 29/01/2020 | 29/01/2020 |
| | | | | 30/01/2020 | 30/01/2020 |
| | | | | 31/01/2020 | 31/01/2020 |
| | | | | ... | ... |
| | | | | 11/05/2020 | 11/05/2020 |
+----------+------------------+--------------+-----------+-------------+------------+
The List.Dates function is pretty useful here.
Generate the dates in your range, duplicate that to two columns and then append.
let
StartDate = List.Min(StartTable[Start Date]),
EndDate = List.Max(StartTable[End Date]),
DateList = List.Dates(StartDate, Duration.Days(EndDate - StartDate), #duration(1,0,0,0)),
DateCols = Table.FromColumns({DateList, DateList}, {"Start Date", "End Date"}),
AppendDates = Table.Combine({StartTable, DateCols})
in
AppendDates
i have database scheme like this.
# periode
+------+--------------+--------------+
| id | from | to |
+------+--------------+--------------+
| 1 | 2018-04-12 | 2018-05-11 |
| 2 | 2018-05-12 | 2018-06-11 |
+------+--------------+--------------+
# foo
+------+---------+
| id | name |
+------+---------+
| 1 | John |
| 2 | Doe |
| 3 | Trodi |
| 4 | son |
| 5 | Alex |
+------+---------+
#bar
+------+---------------+--------------+
| id | employee_id | periode_id |
+------+---------------+--------------+
| 1 | 1 |1 |
| 2 | 2 |1 |
| 3 | 1 |2 |
| 4 | 3 |1 |
+------+---------------+--------------+
I need to show employee that not in salary.
for now I do like this
queryset=Bar.objects.all().filter(periode_id=1)
result=Foo.objects.exclude(id=queryset)
but its fail, how do filter employee list not in salary?...
Well here you basically want the foos such that there is no period_id=1 in the Bar table.
We can let this work with:
ex = Bar.objects.all().filter(periode_id=1).values_list('employee_id', flat=True)
result=Foo.objects.exclude(id__in=ex)
I have a Django model with three fields: product, condition and quantity with data such as:
| Product | Condition | Quantity |
+---------+-----------+----------+
| A | new | 2 |
| A | new | 3 |
| A | new | 4 |
| A | old | 1 |
| A | old | 2 |
| B | new | 2 |
| B | new | 3 |
| B | new | 1 |
| B | old | 4 |
| B | old | 2 |
I'd like to sum the quantities of the entries where product and condition are equal:
| Product | Condition | Quantity |
+---------+-----------+----------+
| A | new | 9 |
| A | old | 3 |
| B | new | 6 |
| B | old | 6 |
This answer helps to count entries with the same field value, but I need to count two fields.
How could I implement this?
from django.db.models import Sum
Model.objects.values('product', 'condition').order_by().annotate(Sum('quantity'))
I have a fasta file of +20k intronic sequences with the following headers I can describe as:
>ENSG[0-9] | ENST[0-9] | start_position | end_position | name |
I would like to change positions of ENSG[0-9] and ENST[0-9] and add "NASCENT" to ENST[0-9] pattern.
I tried:
sed 's/\(ENSG\d*\) *| *\(ENST\d*\) */\2 | \1/'
to first just focus on repositioning, but to no avail. It's probably escapes that I've confused.
Any hint or a better solution?
Not 100% sure if I got your input format correct but if an example file would like this:
>ENSG1 | ENST1 | 1 | 3 | name1 |
ATG
>ENSG2 | ENST2 | 4 | 9 | name2 |
ATGATG
>ENSG12 | ENST12 | 10 | 17 | name12 |
ATGATGATG
calling sed with the following parameters:
sed 's/\(ENSG[0-9]\+\).*\(ENST[0-9]\+\)\(.*\)/NASCENT_\2 | \1\3/g'
would give you
>NASCENT_ENST1 | ENSG1 | 1 | 3 | name1 |
ATG
>NASCENT_ENST2 | ENSG2 | 4 | 9 | name2 |
ATGATG
>NASCENT_ENST12 | ENSG12 | 10 | 17 | name12 |
ATGATGATG
I want to implement a N-level tree structure in android. I have gone through the ExpandableListView, but it is applicable for only 2 or 3 levels. My requirement is as below...
CAR
|
|==Toyota
| |
| |==Sedan
| | |
| | |==Camry
| | | |
| | | |==Manufacture year
| | | |==Body Colour
| | | | |
| | | | |==Black
| | | | |==Blue
| | | | |==Red
| | | |
| | | |==Alloy Wheels
| | | |==CD player
| | | |==Petrol/Diesel
| | |
| | |==Yaris
| | |
| | |==Manufacture year
| | |==Body Colour
| | | |
| | | |==Black
| | | |==Blue
| | | |==Red
| | |
| | |==Alloy Wheels
| | |==CD player
| | |==Petrol/Diesel
| |
| |==Hatch Pack
| | |
| | |==Yaris
| | |
| | |==Manufacture year
| | |==Body Colour
| | | |
| | | |==Black
| | | |==Blue
| | | |==Red
| | |
| | |==Alloy Wheels
| | |==CD player
| | |==Petrol/Diesel
| |
| |
| |
| |==Four Wheel Drive
|
|
|==Mazda
|
| This section will have
| same classification as above
|
|==Nissan
|
| This section will have
| same classification as above
|
|==Ferrari
|
| This section will have
| same classification as above
|
|==Hyundai
|
| This section will have
| same classification as above
|
Do you ppl have any suggestions to implement this in Android. A sample code would be more helpful. Thanks in advance.